Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-59572

Task report macro uses "username" fields to join tables (instead of lower_username)

XMLWordPrintable

      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

      1. Prepare a Confluence instance with a lot of inline tasks and pages
      2. Create a page and add a task report macro sorted by "assignee"
      3. Enable SQL logging in Confluence
      4. Open a page with task report macro
      5. 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".

              glipatov George Lipatov
              glipatov George Lipatov
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: