cancel
Showing results for 
Search instead for 
Did you mean: 

performance issue with candidate tasks

miroslav_slobod
Champ in-the-making
Champ in-the-making
Hello,
I am testing Activiti framework from performance perspective. Actually I found problem with candidate tasks query performance if I have about 300 000 process instance in database. Problem is with this lines of code where I want to find out CANDIDATE tasks for concrete user:


org.activiti.engine.TaskService taskService = processEngine.getTaskService();
TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery = taskQuery.taskCandidateUser(userId).orderByTaskCreateTime().asc();
List<org.activiti.engine.task.Task> list = taskQuery.listPage(0, MAX_TASKS_RESULTS);

This generates this  DB select:


SELECT DISTINCT t. *
FROM act_ru_task t
INNER JOIN act_ru_identitylink i
ON i.task_id_    = t.id_
WHERE i.type_    = 'candidate'
AND i.group_id_ IN ( 'DISPATCHER' )
AND t.assignee_ IS NULL
ORDER BY t.create_time_ ASC

This query is executed about 8 seconds. I am using Activiti 5.9 with Oracle 11g database on Linux machines. All other queries are executed within milliseconds.
I tried to found out where the problem is and it is with IS NULL condition in assignee_ column. If I changed condition in SQL to IS NOT NULL or = '1' the query is executed in milliseconds.

So I realized that the problem is only with candidate tasks where assignee is not set (IS NULL).

Do you have some solution to fix it?

Thank you in advance.
5 REPLIES 5

trademak
Star Contributor
Star Contributor
Hi,

Interesting. Could it be some sort of index problem?
Can you compare the Oracle query path between the ASSIGNEE IS NULL and the ASSIGNEE IS NOT NULL query statements?

Best regards,

miroslav_slobod
Champ in-the-making
Champ in-the-making
Hello,
I am not a database expert, but I tried to add some database indexes - performance did not improve. There are attached two explain plans from Oracle SQL Developer.

I am not sure if this is what you requested.

Best regards.

miroslav_slobod
Champ in-the-making
Champ in-the-making
Some idea?

heymjo
Champ on-the-rise
Champ on-the-rise
Interesting, we're using Oracle as well so i had a look into this. It turns out that Oracle does not always use the index for a NULL column value in the where clause. See here http://stackoverflow.com/questions/1017239/how-do-null-values-affect-performance-in-a-database-searc.... It says that you could solve the problem by adding a constant to the index:

CREATE INDEX idx_null ON test(object_id, 1);

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Great catch…