Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-13793

‘Checks executed after computation of measures’ step can take a lot of time

    XMLWordPrintable

    Details

    • Edition:
      Community
    • Production Notes:
      None

      Description

      Description

      ‘Checks executed after computation of measures’ step can take a lot of time for some users, between 11 and 18 seconds.

      Investigation

      This issue is coming from the following SQL request.

      In this context, the SQL request is not using the index "LIVE_MEASURES_COMPONENT" on "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_UUID") is not used, which makes the query do a full scan of the "LIVE_MEASURES" table.

      How to fix

      One solution would be to not use the "COMPONENTS" table to query projects, but to use the new "PROJECTS" table.

      The new query would be :

      select sum(sumncloc.maxncloc) from ( 
         select b.project_uuid as projectUuid, max(lm.value) as maxncloc 
            from live_measures lm 
            inner join metrics m on m.id = lm.metric_id and m.name = 'ncloc'   
            inner join project_branches b on b.uuid = lm.component_uuid and b.branch_type = 'BRANCH'
            inner join projects p on p.uuid = b.project_uuid and p.private=true and p.qualifier = 'TRK' 
            group by b.project_uuid 
      ) sumncloc;
      

      (This query would only work starting 8.2 using new projects table introduced by SONAR-13142)

       

      Implementation note: the suggested fix does improve the query performance in theory. Note that our tests on a 800Gb PostgreSQL database did not demonstrate a real-world improvement, as the PostgreSQL optimizer is using the index on live_measure in our case. We decided to merge this anyway, because it's theoretically better. Results will vary depending on the dataset structure & balance.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pierre.guillot Pierre Guillot
              Reporter:
              julien.lancelot Julien Lancelot
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: