工做流性能優化(敢問activiti有擴展性?)(2)

2015/4/17java

粗略看了activiti的sql的,在ativity engine包裏邊;mysql

沒什麼頭緒,先用excel記錄數據量少的時候本機的性能狀況;spring

 

不打印hibernate的sql;一刷一大片,還不輸出參數是什麼,這樣的語句有什麼意義哦,懷念mybatis;sql

<property name="showSql" value="false" />apache

 

讓程序充分加載,取第三次的結果:編程

開始時間:2015-04-17 09:38:20.611mybatis

總記錄數:57app

結束時間:2015-04-17 09:38:22.788框架

總耗時:2177毫秒。ide

開始時間:2015-04-17 09:39:24.174

總記錄數:57

結束時間:2015-04-17 09:39:26.110

總耗時:1936毫秒。

開始時間:2015-04-17 09:39:30.521

總記錄數:57

結束時間:2015-04-17 09:39:32.331

總耗時:1810毫秒。

 

設置打印activiti中mybatis的sql;

<logger name="org.apache.ibatis.jdbc.ScriptRunner" level="DEBUG"/>

<!-- 目前本人只知道這句最有用 -->

<logger name="org.activiti.engine.impl.persistence.entity" level="DEBUG"/>

<!-- 下面是其餘帖子抄的不知道有什麼用 -->

<logger name="java.sql.Connection" level="DEBUG"/>

<logger name="java.sql.Statement" level="DEBUG"/>

<logger name="java.sql.PreparedStatement" level="DEBUG"/>

<logger name="java.sql.ResultSet" level="DEBUG"/>

 

配置logback;

slf4j包衝突的,在pom.xml裏邊指定slf4j的版本就能夠;

 

數據語句:

2015-04-17 10:25:30.487 DEBUG org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria - ooo Using Connection [Transaction-aware proxy for target Connection from DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@192db17]]

2015-04-17 10:25:30.487 DEBUG org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria - ==> Preparing: select RES.* from ACT_HI_PROCINST RES WHERE ( exists(select LINK.USER_ID_ from ACT_HI_IDENTITYLINK LINK where USER_ID_ = ? and LINK.PROC_INST_ID_ = RES.ID_) ) order by RES.START_TIME_ desc LIMIT ? OFFSET ?

2015-04-17 10:25:30.488 DEBUG org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria - ==> Parameters: 324(String), 2147483647(Integer), 0(Integer)

愛死mybatis,要啥有啥;

 

這裏感受沒分頁啊;

找出涉及哪些表,而後手工拼接數據,成功插入了1條數據;

寫程序插入數據;

NM,activiti新增條記錄都n麻煩,能不能好好編程了;

clip_image002

 

換mysql存儲過程,不錯哦;

delimiter $$

use `keyan2`$$

drop procedure if exists `insert_task`$$

create definer=`root`@`localhost` procedure `insert_task`()

begin

declare beginId int default 100000;

declare detailId int default 100000;

declare actinstId int default 100000;

declare actinstId_org int default 100000;

declare varinstId int default 100000;

declare PROC_DEF_ID_ varchar(255) default 'process_38869:8:87533';

declare ACT_ID_ varchar(255) default 'sid-6EFEBB5D-1A5A-4737-TEST-A255D5';

declare TASK_DEF_KEY_ varchar(255) default 'sid-6EFEBB5D-1A5A-4737-TEST-A255D8';

declare num int default 0;

while num < 1000 do

insert into `keyan2`.`act_ru_execution` (`ID_`, `REV_`, `PROC_INST_ID_`, `PROC_DEF_ID_`, `ACT_ID_`, `IS_ACTIVE_`, `IS_CONCURRENT_`, `IS_SCOPE_`, `IS_EVENT_SCOPE_`, `SUSPENSION_STATE_`,

`CACHED_ENT_STATE_`) values (beginId, '1', beginId, PROC_DEF_ID_, concat(ACT_ID_, beginId), '1', '0', '1', '0', '1', '2');

insert into `keyan2`.`act_ru_task` (`ID_`, `REV_`, `EXECUTION_ID_`, `PROC_INST_ID_`, `PROC_DEF_ID_`, `NAME_`, `TASK_DEF_KEY_`, `ASSIGNEE_`, `PRIORITY_`, `CREATE_TIME_`, `SUSPENSION_STATE_`)

values (beginId, '1', beginId, beginId, PROC_DEF_ID_, '編制', concat(TASK_DEF_KEY_, beginId), '324', '50', now(), '1');

insert into `keyan2`.`act_hi_taskinst` (`ID_`, `PROC_DEF_ID_`, `TASK_DEF_KEY_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `ASSIGNEE_`, `START_TIME_`, `PRIORITY_`)

values (beginId, PROC_DEF_ID_, concat(TASK_DEF_KEY_, beginId), beginId, beginId, '編制', '324', now(), '50');

insert into `keyan2`.`act_hi_procinst` (`ID_`, `PROC_INST_ID_`, `PROC_DEF_ID_`, `START_TIME_`, `START_USER_ID_`, `START_ACT_ID_`)

values (beginId, beginId, PROC_DEF_ID_, now(), '324', concat(ACT_ID_, beginId));

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`)

values (detailId, 'VariableUpdate', beginId, beginId, 'user0', 'string', '0', now(),'324');

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`)

values (detailId, 'VariableUpdate', beginId, beginId, '$category$', 'string', '0', now(),'information', actinstId);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`)

values (detailId, 'VariableUpdate', beginId, beginId, '$processDefinitionKey$', 'string', '0', now(),'process_38869', actinstId);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`, `LONG_`)

values (detailId, 'VariableUpdate', beginId, beginId, '$startUser$', 'long', '0', now(),'324', actinstId, '324');

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`)

values (detailId, 'VariableUpdate', beginId, beginId, '$title$', 'string', '0', now(), concat('TEST', beginId), actinstId);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `ACT_INST_ID_`, `BYTEARRAY_ID_`)

values (detailId, 'VariableUpdate', beginId, beginId, '$start#91462.formDefinition$', 'serializable', '0', now(), actinstId, '91480');

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `ACT_INST_ID_`, `BYTEARRAY_ID_`)

values (detailId, 'VariableUpdate', beginId, beginId, '$projectNode$', 'bytes', '0', now(), actinstId, '91485');

set actinstId_org = actinstId;

insert into `keyan2`.`act_hi_actinst` (`ID_`, `PROC_DEF_ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `ACT_ID_`, `ACT_NAME_`, `ACT_TYPE_`, `START_TIME_`, `END_TIME_`, `DURATION_`)

values (actinstId, PROC_DEF_ID_, beginId, beginId, concat('sid-6EFEBB5D-1A5A-4737-TEST-A255D8', actinstId), '開始', 'startEvent', now(), now(), '0');

set actinstId = actinstId+1;

insert into `keyan2`.`act_hi_actinst` (`ID_`, `PROC_DEF_ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `ACT_ID_`, `TASK_ID_`, `ACT_NAME_`, `ACT_TYPE_`, `ASSIGNEE_`, `START_TIME_`)

values (actinstId, PROC_DEF_ID_, beginId, beginId, concat('sid-6EFEBB5D-1A5A-4737-TEST-A255D8', actinstId), actinstId_org, '編制', 'userTask', '324', now());

insert into `keyan2`.`act_hi_identitylink` (`ID_`, `TYPE_`, `USER_ID_`, `PROC_INST_ID_`) values (beginId, 'starter', '324', beginId);

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, 'user0', 'string', '0', '324');

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, '$category$', 'string', '0', 'information');

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, '$processDefinitionKey$', 'string', '0', 'process_38869');

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`, `LONG_`)

values (varinstId, beginId, beginId, '$startUser$', 'long', '0', '324', '324');

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, '$title$', 'string', '0', concat('TEST', beginId));

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `BYTEARRAY_ID_`)

values (varinstId, beginId, beginId, '$start#91462.formDefinition$', 'serializable', '0', '91479');

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `BYTEARRAY_ID_`)

values (varinstId, beginId, beginId, '$projectNode$', 'bytes', '0', '91484');

set num = num + 1;

set beginId = beginId + 1;

set detailId = detailId + 1;

set actinstId = actinstId + 1;

set varinstId = varinstId + 1;

end while;

end$$

delimiter ;

 

發現這activiti傻的,取出全部待辦數據,而後在程序裏邊過濾數據,而後再作分頁查詢;

生成了1000數據,測試一把:

Catch(04-23-17-15-29)

 

明顯地分頁優化完勝,問了下LTW優化的兄弟;回答是:由於原有的配置,就是不加LoadTimeWeaver的配置,會致使ORM的LazyLoad無效,等同於全部關聯的實體都會被加載;

 

分頁優化還要改不少代碼,activiti缺少靈活性真的有體會了;

不行咱就本身寫SQL;

先試試代碼上改吧;

/org/activiti/db/mapping/entity/HistoricProcessInstance.xml居然沒有關聯act_hi_taskinst的地方;

 

什麼鬼,這能算優秀框架嗎?我加個.variableValueEquals("ASSIGNEE_", String.valueOf(userInfo.getId()))查詢,出來這樣的語句,select count(distinct RES.ID_) from ACT_HI_PROCINST RES inner join ACT_HI_VARINST A0 on RES.PROC_INST_ID_ = A0.PROC_INST_ID_ WHERE RES.END_TIME_ IS NULL and ( exists(select LINK.USER_ID_ from ACT_HI_IDENTITYLINK LINK where USER_ID_ = ? and LINK.PROC_INST_ID_ = RES.ID_) ) and A0.NAME_= ? and A0.VAR_TYPE_ = ? and A0.TEXT_ = ?,Parameters: 324(String), ASSIGNEE_(String), string(String), 324(String),什麼龜?

 

還得深刻mapper.xml文件看看;

又糾結了,這怎麼辦?

相關文章
相關標籤/搜索