]> source.dussan.org Git - sonarqube.git/commit
[NO-JIRA] optimize slow selectProjectUuidsAssociatedToDefaultQualityProfileByLanguage
authorThomas de Grenier de Latour <thomas.degrenierdelatour@orange.com>
Wed, 1 Mar 2023 23:49:03 +0000 (00:49 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 9 Mar 2023 20:02:59 +0000 (20:02 +0000)
commitac52dfa0e238a35355a885155c1188af06fdd83e
treee71f020be98bacfdf479c891cf2095246c516746
parent273f7412c5a26b9c18abed66c7ffc154a94e9746
[NO-JIRA] optimize slow selectProjectUuidsAssociatedToDefaultQualityProfileByLanguage

The project DAO `selectProjectUuidsAssociatedToDefaultQualityProfileByLanguage`
SQL query implies scanning through many rows of the `live_measures` table . This
takes several minutes to execute in some setups (Postgres 13, 200M rows in the
table), making SonarQube upgrades painfully slow (this request is executed for
each update of a bundled quality profile).

A similar query can be achieved by joining the `projects` table, with a drastic
improvement to the execution plan. The results are not the same though: this new
version only returns uuids of actual projects, whereas the original one also
returns uuids of other components (not existing in the projects table). But this
is actually an improvement too: the only call sites for this DAO method (in
`QualityProfileChangeEventServiceImpl`) uses the results as an input for the
`ProjectDAO.selectByUuids()` method, which only looks at the `projects` table.
server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml