Hi again,
We analyzed the query which is fired against database.
The following query is the actual one which is very slow.
SELECT DISTINCT RES.REV_
,RES.ID_
,RES.NAME_
,RES.PARENT_TASK_ID_
,RES.DESCRIPTION_
,RES.PRIORITY_
,RES.CREATE_TIME_
,RES.OWNER_
,RES.ASSIGNEE_
,RES.DELEGATION_
,RES.EXECUTION_ID_
,RES.PROC_INST_ID_
,RES.PROC_DEF_ID_
,RES.CASE_EXECUTION_ID_
,RES.CASE_INST_ID_
,RES.CASE_DEF_ID_
,RES.TASK_DEF_KEY_
,RES.DUE_DATE_
,RES.FOLLOW_UP_DATE_
,RES.SUSPENSION_STATE_
,RES.TENANT_ID_
FROM ACT_RU_TASK RES
INNER JOIN ACT_RE_PROCDEF D ON RES.PROC_DEF_ID_ = D.ID_
LEFT JOIN ACT_RE_PROCDEF PROCDEF ON RES.PROC_DEF_ID_ = PROCDEF.ID_
LEFT JOIN
(SELECT A.*
FROM ACT_RU_AUTHORIZATION A
WHERE A.TYPE_ < 2
AND ( A.USER_ID_ IN ('l.mittellos', '*')
OR A.GROUP_ID_ IN ('DEPARTMENT_GROUP'))
AND (( A.RESOURCE_TYPE_ = 7 AND A.PERMS_ & 2 = 2
OR A.RESOURCE_TYPE_ = 6 AND A.PERMS_ & 64 = 64))) AUTH
ON (AUTH.RESOURCE_ID_ IN (RES.ID_, PROCDEF.KEY_, '*'))
WHERE RES.ASSIGNEE_ IS NULL
AND D.NAME_ LIKE '%%'
AND ( (RES.CASE_EXECUTION_ID_ IS NOT NULL)
OR (AUTH.RESOURCE_ID_ IS NOT NULL))
AND (RES.TENANT_ID_ IS NULL)
ORDER BY RES.PRIORITY_ DESC, RES.CREATE_TIME_ DESC
LIMIT 11
OFFSET 0
It took more than 1 minute on a mysql database with 8200 entries in ACT_RU_TASK.
Authorization is enabled.
We refactored this query to use a union.
SELECT DISTINCT RES.REV_
,RES.ID_
,RES.NAME_
,RES.PARENT_TASK_ID_
,RES.DESCRIPTION_
,RES.PRIORITY_
,RES.CREATE_TIME_
,RES.OWNER_
,RES.ASSIGNEE_
,RES.DELEGATION_
,RES.EXECUTION_ID_
,RES.PROC_INST_ID_
,RES.PROC_DEF_ID_
,RES.CASE_EXECUTION_ID_
,RES.CASE_INST_ID_
,RES.CASE_DEF_ID_
,RES.TASK_DEF_KEY_
,RES.DUE_DATE_
,RES.FOLLOW_UP_DATE_
,RES.SUSPENSION_STATE_
,RES.TENANT_ID_
FROM ACT_RU_TASK RES
INNER JOIN ACT_RE_PROCDEF D ON RES.PROC_DEF_ID_ = D.ID_
JOIN ACT_RE_PROCDEF PROCDEF ON RES.PROC_DEF_ID_ = PROCDEF.ID_
JOIN
(SELECT A.*
FROM ACT_RU_AUTHORIZATION A
WHERE A.TYPE_ < 2
AND ( A.USER_ID_ IN ('l.mittellos', '*')
OR A.GROUP_ID_ IN ('DEPARTMENT_GROUP'))
AND (( A.RESOURCE_TYPE_ = 7 AND A.PERMS_ & 2 = 2
OR A.RESOURCE_TYPE_ = 6 AND A.PERMS_ & 64 = 64))) AUTH
ON (AUTH.RESOURCE_ID_ IN (RES.ID_, PROCDEF.KEY_, '*'))
WHERE RES.ASSIGNEE_ IS NULL
AND D.NAME_ LIKE '%%'
AND (RES.TENANT_ID_ IS NULL)
union
SELECT DISTINCT RES.REV_
,RES.ID_
,RES.NAME_
,RES.PARENT_TASK_ID_
,RES.DESCRIPTION_
,RES.PRIORITY_
,RES.CREATE_TIME_
,RES.OWNER_
,RES.ASSIGNEE_
,RES.DELEGATION_
,RES.EXECUTION_ID_
,RES.PROC_INST_ID_
,RES.PROC_DEF_ID_
,RES.CASE_EXECUTION_ID_
,RES.CASE_INST_ID_
,RES.CASE_DEF_ID_
,RES.TASK_DEF_KEY_
,RES.DUE_DATE_
,RES.FOLLOW_UP_DATE_
,RES.SUSPENSION_STATE_
,RES.TENANT_ID_
FROM ACT_RU_TASK RES
INNER JOIN ACT_RE_PROCDEF D ON RES.PROC_DEF_ID_ = D.ID_
JOIN ACT_RE_PROCDEF PROCDEF ON RES.PROC_DEF_ID_ = PROCDEF.ID_
WHERE RES.ASSIGNEE_ IS NULL
AND D.NAME_ LIKE '%%'
AND RES.CASE_EXECUTION_ID_ IS NOT NULL
AND (RES.TENANT_ID_ IS NULL)
ORDER BY PRIORITY_ DESC, CREATE_TIME_ DESC
LIMIT 11
OFFSET 0;
Its the same result but it takes only about 3 seconds to execute it.
Maybe the query which is executed in version 7.7 could be refactored in one of the next versions because in combination with authorization it is very slow at the moment.
Best regards,
Markus