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

Fix/mnt 24335 performance issue wf tests with unit tests #4637

Open
wants to merge 10 commits into
base: 7.11.x
Choose a base branch
from
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- 7.11.x
- fix/MNT-24335-performance_issue_WF_tests_withUnitTests
pull_request:
branches:
- 7.11.x
- fix/MNT-24335-performance_issue_WF_tests_withUnitTests
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@

<select id="selectHistoricTaskInstanceCountByQueryCriteria" parameterType="org.activiti.engine.impl.HistoricTaskInstanceQueryImpl" resultType="long">
select count(DISTINCT RES.ID_)
<include refid="selectHistoricTaskInstancesByQueryCriteriaSql"/>
<include refid="selectHistoricTaskInstancesByQueryCriteriaSql">
<property name="selectCount" value="yes"/>
</include>
</select>

<sql id="selectHistoricTaskInstancesByQueryCriteriaSql">
Expand Down Expand Up @@ -358,8 +360,12 @@
</sql>

<sql id="commonSelectHistoricTaskInstancesByQueryCriteriaSql">
<if test="candidateUser != null || candidateGroups != null || involvedGroups != null">
inner join ${prefix}ACT_HI_IDENTITYLINK HI on HI.TASK_ID_ = RES.ID_
<if test="candidateUser != null || candidateGroups != null || involvedGroups != null || involvedUser != null">
<choose>
<when test="involvedGroups != null || involvedUser != null">left</when>
<otherwise>inner</otherwise>
</choose>
join ${prefix}ACT_HI_IDENTITYLINK HI on HI.TASK_ID_ = RES.ID_
</if>
<if test="processFinished || processUnfinished || processInstanceBusinessKey != null || processInstanceBusinessKeyLike != null || processInstanceBusinessKeyLikeIgnoreCase != null">
inner join ${prefix}ACT_HI_PROCINST HPI ON RES.PROC_INST_ID_ = HPI.ID_
Expand All @@ -381,9 +387,9 @@
</choose>
</foreach>
<foreach collection="orQueryObjects" index="orIndex" item="orQueryObject">
<if test="orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null || orQueryObject.involvedGroups != null">
<if test="orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null || orQueryObject.involvedGroups != null || orQueryObject.involvedUser != null">
<choose>
<when test="orQueryObject.involvedGroups != null">left</when>
<when test="orQueryObject.involvedGroups != null || orQueryObject.involvedUser != null">left</when>
<otherwise>inner</otherwise>
</choose>
join ${prefix}ACT_HI_IDENTITYLINK HI_OR${orIndex} on HI_OR${orIndex}.TASK_ID_ = RES.ID_
Expand Down Expand Up @@ -635,14 +641,29 @@
</if>
)
</if>
<if test="involvedUser != null">
and
(
exists(select LINK.USER_ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where USER_ID_ = #{involvedUser} and LINK.TASK_ID_ = RES.ID_)
or RES.ASSIGNEE_ = #{involvedUser}
or RES.OWNER_ = #{involvedUser}
)
</if>
<choose>
<when test="'${selectCount}' == 'yes'">
<if test="involvedUser != null">
and
(
exists(select LINK.USER_ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where USER_ID_ = #{involvedUser} and LINK.TASK_ID_ = RES.ID_)
or RES.ASSIGNEE_ = #{involvedUser}
or RES.OWNER_ = #{involvedUser}
)
</if>
</when>
<otherwise>
<if test="involvedUser != null">
and
(
HI.USER_ID_ = #{involvedUser}
or RES.ASSIGNEE_ = #{involvedUser}
or RES.OWNER_ = #{involvedUser}
)
</if>
</otherwise>
</choose>

<if test="involvedGroups != null &amp;&amp; involvedGroups.size() &gt; 0">
and
(
Expand Down Expand Up @@ -949,24 +970,31 @@
</if>
))
</if>
<if test="orQueryObject.involvedUser != null">
or
(
exists(select LINK.USER_ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where USER_ID_ = #{orQueryObject.involvedUser} and LINK.TASK_ID_ = RES.ID_)
or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
or RES.OWNER_ = #{orQueryObject.involvedUser}
)
</if>
<choose>
<when test="'${selectCount}' == 'yes'">
<if test="orQueryObject.involvedUser != null">
or
(
exists(select LINK.USER_ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where USER_ID_ = #{orQueryObject.involvedUser} and LINK.TASK_ID_ = RES.ID_)
or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
or RES.OWNER_ = #{orQueryObject.involvedUser}
)
</if>
</when>
<otherwise>
<if test="orQueryObject.involvedUser != null">
or
(
HI_OR${orIndex}.USER_ID_ = #{orQueryObject.involvedUser}
or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
or RES.OWNER_ = #{orQueryObject.involvedUser}
)
</if>
</otherwise>
</choose>

<if test="orQueryObject.involvedGroups != null &amp;&amp; orQueryObject.involvedGroups.size() &gt; 0">
or
(
HI_OR${orIndex}.TYPE_ = 'participant'
and
HI_OR${orIndex}.GROUP_ID_ IN
<foreach item="group" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
#{group}
</foreach>
)
or ( <include refid="orQueryObject_involvedGroups"/> )
</if>
<foreach item="queryVar" collection="orQueryObject.queryVariableValues" index="index">
or
Expand Down Expand Up @@ -1042,10 +1070,29 @@
</trim>
</foreach>
</trim>
<!-- we're using UNION for every situation that doesn't COUNT -->
<if test="'${selectCount}' != 'yes'">
<if test="orQueryObject.involvedGroups != null &amp;&amp; orQueryObject.involvedGroups.size() &gt; 0">
UNION
select distinct RES.*
from ACT_HI_TASKINST RES
left join ACT_HI_IDENTITYLINK HI_OR${orIndex} on HI_OR${orIndex}.TASK_ID_ = RES.ID_
WHERE RES.END_TIME_ is not null
AND ( <include refid="orQueryObject_involvedGroups"/> )
</if>
</if>
</foreach>
</where>
</sql>

<sql id="orQueryObject_involvedGroups">
HI_OR${orIndex}.TYPE_ = 'participant'
and HI_OR${orIndex}.GROUP_ID_ IN
<foreach item="group" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
#{group}
</foreach>
</sql>

<sql id="executionVariableOperator">
<choose>
<when test="queryVar.operator.equals('EQUALS')">=</when>
Expand Down