-
Bug
-
Resolution: Fixed
-
Low
-
6.13.7
-
None
-
1
-
Severity 3 - Minor
-
Issue Summary
When task report macro is sorted by user name ("assignee"), a new join is added to SQL query:
left join cwd_user cu on um.username = cu.user_name
As both um.username and cu.user_name do not have indexes, the database has to scan tables (it leads to performance degradation).
Full SQL query statement:
SELECT DISTINCT t.GLOBAL_ID, t.CONTENT_ID,CASE WHEN cu.lower_display_name IS NULL THEN 0 ELSE 1 END CU_LOWER_DISPLAY_NAME, cu.lower_display_name,t.CREATE_DATE FROM AO_BAF3AA_AOINLINE_TASK t JOIN CONTENT c ON t.CONTENT_ID = c.CONTENTID JOIN SPACES s ON c.SPACEID = s.SPACEID LEFT JOIN user_mapping um ON t.ASSIGNEE_USER_KEY = um.user_key LEFT JOIN cwd_user cu on um.username = cu.user_name WHERE s.SPACESTATUS <> 'ARCHIVED' AND c.CONTENT_STATUS <> 'deleted' AND t.TASK_STATUS = 'UNCHECKED' ORDER BY CU_LOWER_DISPLAY_NAME DESC , cu.lower_display_name ASC , t.CREATE_DATE DESC;
Steps to Reproduce
- Prepare a Confluence instance with a lot of inline tasks and pages
- Create a page and add a task report macro sorted by "assignee"
- Enable SQL logging in Confluence
- Open a page with task report macro
- Retrieve the SQL query from logs and check its execution plan (by using DB tools)
Expected Results
SQL query does not perform full scan on cwd_user and user_mapping tables
Actual Results
SQL query performs full scan on either cwd_user or user_mapping tables (or both)
Workaround
Do not sort tasks by "assignee".