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

Improve performance of WS api/measures/component_tree

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0
    • Component/s: Measures, Web API
    • Labels:

      Description

      /api/measures/component_tree is quite slow on SonarCloud, 6.6-M1
      ie:
      https://sonarcloud.io/api/measures/component_tree?s=metric&metricSort=ncloc&asc=false&ps=500&baseComponentKey=org.apache%3Atomcat%3A8.5.x&metricKeys=sqale_index%2Ccoverage%2Cncloc%2Creliability_rating%2Csecurity_rating&strategy=leaves

      The following SQL request returns 7378 rows and runs between 9 and 12s:

      select  
          pm.metric_id as metricId,
          pm.person_id as developerId,
          pm.component_uuid as componentUuid,
          pm.analysis_uuid as analysisUuid,
          pm.value as value,
          pm.text_value as textValue,
          pm.alert_status as alertStatus,
          pm.alert_text as alertText,
          pm.measure_data as dataValue,
          pm.variation_value_1 as variation
          from project_measures pm
          inner join snapshots analysis on analysis.uuid = pm.analysis_uuid
          inner join projects p on p.project_uuid=analysis.component_uuid and p.uuid=pm.component_uuid
           
          inner join projects base on base.project_uuid = p.project_uuid and base.uuid = ?    
              and p.uuid_path like ? ESCAPE '/'
           WHERE  analysis.islast=true
            and pm.metric_id in
            (?,?,?,?,?)
              and pm.person_id is null
          and p.enabled = true
            and p.qualifier in
            (
              ?
            ,
              ?
            ) 
          -- Add measures of base component
          union all
          select  
          pm.metric_id as metricId,
          pm.person_id as developerId,
          pm.component_uuid as componentUuid,
          pm.analysis_uuid as analysisUuid,
          pm.value as value,
          pm.text_value as textValue,
          pm.alert_status as alertStatus,
          pm.alert_text as alertText,
          pm.measure_data as dataValue,
          pm.variation_value_1 as variation
          from project_measures pm
          inner join snapshots analysis on analysis.uuid = pm.analysis_uuid
          inner join projects p on p.project_uuid=analysis.component_uuid and p.uuid=pm.component_uuid and pm.component_uuid=?
           WHERE  analysis.islast=true
            and pm.metric_id in
            (?,?,?,?,?)
              and pm.person_id is null
          and p.enabled = true
            and p.qualifier in
            (
              ?
            ,
              ?
            ) ['AVjPDJ1rSAbwa7Q_u6JW', '.AVjPDJ1rSAbwa7Q/_u6JW.%', 20, 5, 162, 315, 319, 'FIL', 'UTS', 'AVjPDJ1rSAbwa7Q_u6JW', 20, 5, 162, 315, 319, 'FIL', 'UTS'] 
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              daniel.schwarz Daniel Schwarz (Inactive)
              Reporter:
              simon.brandhof Simon Brandhof (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: