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

Optimize query that return file source hashes in /batch/project WS

    XMLWordPrintable

    Details

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

      Description

      Current query is :

      SELECT
        p.uuid,
        p.path,
        p.module_uuid AS moduleUuid,
        fs.src_hash   AS srcHash
      FROM projects p
        INNER JOIN file_sources fs ON fs.file_uuid = p.uuid
        INNER JOIN projects root_project ON root_project.uuid = p.project_uuid AND root_project.enabled = TRUE
        INNER JOIN projects module ON module.project_uuid = root_project.uuid AND module.uuid = ? AND module.scope = 'PRJ' AND module.enabled = TRUE
      WHERE p.enabled = TRUE AND p.scope = 'FIL' AND p.module_uuid_path LIKE module.module_uuid_path || '%';
      

      The usage of the module_uuid_path is because the same query is used when a project is analysed from the batch and when modules are analysed by IDEs.

      For the first use case, when this WS is called on a project, it should be replaced by :

      SELECT
        p.uuid,
        p.path,
        p.module_uuid AS moduleUuid,
        fs.src_hash   AS srcHash
      FROM projects p
        INNER JOIN file_sources fs ON fs.file_uuid = p.uuid
      WHERE p.enabled = TRUE AND p.scope = 'FIL' AND p.project_uuid = ?;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              julien.lancelot Julien Lancelot
              Reporter:
              julien.lancelot Julien Lancelot
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: