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

Improve performance of /api/qualityprofiles/search WS

    XMLWordPrintable

    Details

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

      Description

      Use case
      SonarLint is using this WS to synchronize quality profiles => when a profile is updated from the server, every client will have to re-synchronize their profiles.
      We should improve its performance in order to hold power.

      Technical details
      The /api/qualityprofiles/search WS is generated one SQL query for each available language when it should generate only one.

      When searching for quality profiles available for a project (For instance
      /api/qualityprofiles/search?projectKey=XXX), here are the list SQL queries generated in log :

      2016.03.14 17:27:24 TRACE web[sql] time=28ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     JOIN project_qprofiles pp ON pp.profile_key=p.kee     JOIN projects project ON pp.project_uuid=project.uuid     AND project.kee=?     WHERE p.language=? | params=org.sonarsource.sonarlint.core:sonarlint-core-parent, xoo
      2016.03.14 17:27:24 TRACE web[sql] time=28ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=xoo
      2016.03.14 17:27:24 TRACE web[sql] time=25ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     JOIN project_qprofiles pp ON pp.profile_key=p.kee     JOIN projects project ON pp.project_uuid=project.uuid     AND project.kee=?     WHERE p.language=? | params=org.sonarsource.sonarlint.core:sonarlint-core-parent, js
      2016.03.14 17:27:24 TRACE web[sql] time=26ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=js
      2016.03.14 17:27:24 TRACE web[sql] time=25ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     JOIN project_qprofiles pp ON pp.profile_key=p.kee     JOIN projects project ON pp.project_uuid=project.uuid     AND project.kee=?     WHERE p.language=? | params=org.sonarsource.sonarlint.core:sonarlint-core-parent, java
      2016.03.14 17:27:24 TRACE web[sql] time=25ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=java
      2016.03.14 17:27:24 TRACE web[sql] time=26ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     JOIN project_qprofiles pp ON pp.profile_key=p.kee     JOIN projects project ON pp.project_uuid=project.uuid     AND project.kee=?     WHERE p.language=? | params=org.sonarsource.sonarlint.core:sonarlint-core-parent, cs
      2016.03.14 17:27:24 TRACE web[sql] time=26ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=cs
      

      When searching for default quality profiles (/api/qualityprofiles/search?defaults=true), here are the SQL queries generated :

      2016.03.14 17:31:32 TRACE web[sql] time=27ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=xoo
      2016.03.14 17:31:32 TRACE web[sql] time=25ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=js
      2016.03.14 17:31:32 TRACE web[sql] time=24ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=java
      2016.03.14 17:31:32 TRACE web[sql] time=24ms | sql=SELECT           p.id as id,     p.kee as kee,     p.name as name,     p.language as language,     p.parent_kee as parentKee,     p.is_default as isDefault,     p.created_at as createdAt,     p.updated_at as updatedAt,     p.rules_updated_at as rulesUpdatedAt         FROM rules_profiles p     WHERE p.is_default=true     AND p.language=? | params=cs
      

      => A SQL query is generated for each language available on the server, we should generated only one SQL.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sebastien.lesaint Sebastien Lesaint
              Reporter:
              julien.lancelot Julien Lancelot
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: