AnsweredAssumed Answered

Extremely slow TaskQuery execution with logical operators and paging

Question asked by xvelez on Jan 25, 2016
Latest reply on Jan 26, 2016 by jbarrez
Hello.

We have a 30,000 task activiti-generated DB. We're trying to fix some performance issues when querying to obtain unassigned tasks with a number of different process variables with paging.

So I modified our current TaskQuery method from this (which already includes paging but not iterating over different process variables):


protected List<Task> findUnassignedTasks(TASK taskKey, VARIABLE processVariable, int page, int size) {
        int offset = page * size;
        return buildBaseTaskQuery().
                processVariableValueEquals(processVariable.getKey(), processVariable.getValue()).
                includeProcessVariables().
                taskUnassigned().
                taskDefinitionKey(taskKey.getKey()).
                listPage(offset, size);
    }

//<TASK extends TaskKey, VARIABLE extends ProcessVariable>


To this:

protected List<Task> findUnassignedTasks(TASK taskKey, VARIABLE[] processVariables, int page, int size) {
        int offset = page * size;
        TaskQuery taskQuery = buildBaseTaskQuery().or();
        for (int i = 0; i < processVariables.length; i++) {
            taskQuery.processVariableValueEquals(processVariables.getKey(), processVariables.getValue());
        }
        taskQuery.endOr();

        return taskQuery.
                includeProcessVariables().
                taskUnassigned().
                taskDefinitionKey(taskKey.getKey()).
                listPage(offset, size);
    }


But this query takes so long that it goes on timeout… What can I do to speed things up? Am I missing something?

I have tried removing the process variable inclusion but we need it in order to obtain the assignee and other information. Is there a way I could request specific process variables?

Outcomes