Performance issue in querying active tasks

We are using task service to retrieve running tasks using the taskService

the query also filters on task assignee and couple of other taskvariables and processvariables

The full API call will look like somewhat the following
taskService.createTaskQuery().includeProcessVariables().includeTaskLocalVariables().or().taskVariableValueEquals("DEPARTMENT_ID", departmentID).taskVariableValueEquals("DEPARTMENT_ID", departmentID2).endOr().processDefinitionKey("myProcess_v1").or(). .processVariableValueEquals(FLOW_STATUS, status).endor().listPage(0,25)

I have 551 objects in ACT_RU_TASK and 42100 objects in the ACT_RU_VARIABLE table.

The response is taking more than 30 seconds sometimes.
When I turned on the debugging and wrote a test, I found the following log

Preparing: select * from ACT_GE_BYTEARRAY where ID_ = ? 
DEBUG selectVariableByteArray - ====> Parameters: 0088cb1f-b18a-11eb-8819-0242ac120002(String)
DEBUG selectVariableByteArray - <====      Total: 1

The above log came almost 450 times.
How can I improve the performance?
I also have 17939 objects in the ACT_HI_TASKINST table

Hi,

My guess is that including process variables into tasks means that you are fetching all process variables for all tasks (including vars stored in bytearray). In that case I woul omit includeProcessVariables()
There were changes in the queries in the latest flowable version (snapshot), which can improve performance.

Regards
Martin

Hi Martin,
Thanks for the response. We use flowable 6.5.0
We need the process variables as well for some business logic. We have around 20-30 process variables per task. But we need only 4 or 5 process variables for our business logic.
What is the recommended approach in this case.

From my point of view (I do not know your project details) I would use custom queries to get the values form the flowable DB.

Regards
Martin

1 Like

FYI: we’ve done a major refactoring of this particular logic, see Rework how we do paging and including data from other tables by filiphr · Pull Request #2892 · flowable/flowable-engine · GitHub

any release coming out soon?