Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

act_ru_variable表增加索引以提升查询性能 #4566

Open
TwilightTian opened this issue Feb 6, 2024 · 0 comments
Open

act_ru_variable表增加索引以提升查询性能 #4566

TwilightTian opened this issue Feb 6, 2024 · 0 comments

Comments

@TwilightTian
Copy link

我们在生产中环境中发现位于activiti-core/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/VariableInstance.xml中以下查询sql存在耗时异常问题

 <select id="selectVariablesByExecutionId"
   parameterType="org.activiti.engine.impl.db.ListQueryParameterObject"
   resultMap="variableInstanceResultMap">
   select * from ${prefix}ACT_RU_VARIABLE
   where EXECUTION_ID_ = #{parameter, jdbcType=VARCHAR}
   and TASK_ID_ is null
 </select>

 <select id="selectVariablesByExecutionIds"
   parameterType="org.activiti.engine.impl.db.ListQueryParameterObject"
   resultMap="variableInstanceResultMap">
   select * from ${prefix}ACT_RU_VARIABLE
   where TASK_ID_ is null
   and EXECUTION_ID_ in
   <foreach item="item" index="index" collection="parameter" open="(" separator="," close=")">
     #{item}
   </foreach>
 </select>

可以通过对act_ru_variable表字段EXECUTION_ID_增加索引来提升查询性能。

ALTER TABLE `act_ru_variable` 
ADD INDEX `ACT_IDX_EXECUTION_ID_`(`EXECUTION_ID_`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant