perf(engine): use EXISTS for task authorization queries#3152
Conversation
Backport CIBSeven fd12ffc2e422683ec9e41ccb82ff3bafe4d8b19c. Original author: vladgrind <156691737+vladgrind@users.noreply.github.com>.
2237040 to
fe9fc07
Compare
|
javahippie
left a comment
There was a problem hiding this comment.
This change brings performance improvements in theory, but I would like to see benchmarks or user experience reports before merging this, especially because it removes previous work which concerned performance (see inline comment)
|
I ran a focused benchmark for the authorization SQL change, specifically against the MySQL/MariaDB concern from the inline review. Compared commit Setup:
Results, average duration per query:
P95 showed the same direction:
So even though the new |
|
Follow-up: I also ran the same focused benchmark against PostgreSQL. Compared commit Setup:
Results, average duration per query:
P95:
PostgreSQL shows the same overall direction: the new |
|
The measurements you did are impressive. From what I read from the change the risk is limited and non-breaking. I would like to have that change. We are in early 2.2 state, so users have also the chance to report. Beyond that, could you share the benchmark tool? Would be valuable to have it and run frequently on defined hardware. |
|
i added the test program used in this PR #3202 |
|
Feel free to merge, could make sense to include it in the 2.2.0-M1 release |



Summary
Backports the CIBSeven task-query authorization SQL optimization to Operaton.
The old task query joins
ACT_RU_AUTHORIZATIONinto the main task result set and then checksAUTH.RESOURCE_ID_ IS NOT NULLin the contextual authorization block. This patch keeps the existing contextual authorization semantics but evaluates task-query authorizations through anEXISTSsubquery instead of the main join. The goal is to avoid inflating the task result set during task list and task count queries.What changes
AuthorizationEntity.authCheckForTaskQueryWithExistsClause.authCheckJoinWithoutOnClauseWithBindingto be reused without emittinginner join/left joinwhen it is embedded in theEXISTSsubquery.AUTHjoin fromTask.xmlfor non-revoke task queries.applyAuthorizationCheckForTaskQueryFast.Source attribution
Backported from CIBSeven:
fd12ffc2e422683ec9e41ccb82ff3bafe4d8b19cimprove(engine): use fast authentication check with EXISTS clause in the task-count and task-selection queries<156691737+vladgrind@users.noreply.github.com>Operaton adaptation:
org.cibseventoorg.operaton.Reviewer notes
This PR intentionally changes SQL shape, not authorization rules. The acceptance question is whether the generated SQL is equivalent across Operaton's supported databases while improving task-list/count performance.
Important review points:
EXISTS (...)overACT_RU_AUTHORIZATIONinstead of a mainAUTHjoin.authorizationCheckCASE path.applyAuthorizationCheckForCaseInstances.authCheckMethodSuffix.Verification
./mvnw -pl engine -Dtest=TaskAuthorizationTest,TaskCountByCandidateGroupAuthorizationTest,VariableInstanceAuthorizationTest,ActivityStatisticsAuthorizationTest test -Dskip.frontend.build=true