aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-10-04 12:38:39 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-10-04 17:23:23 +0200
commit4939863d74224188de391caf19a955322dc3f0b9 (patch)
tree29897e4554eef86d988e782edb5a4157878cd3b5 /server/sonar-db-dao/src
parentd42b199206f3b61624695e5d72109618e1dd0ecf (diff)
downloadsonarqube-4939863d74224188de391caf19a955322dc3f0b9.tar.gz
sonarqube-4939863d74224188de391caf19a955322dc3f0b9.zip
SONAR-9909 Slow indexing of portfolios at server startup
The inner join is super slow because there's no index on column copy_component_uuid. The join is a safeguard to ensure presence of project reference. Dropping it is acceptable as long as the model is supposed to be consistent. Any potential inconsistent states will have to be fixed at the root.
Diffstat (limited to 'server/sonar-db-dao/src')
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml12
1 files changed, 7 insertions, 5 deletions
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index d35ba1ef4d6..0a4b557880c 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -392,12 +392,14 @@
</select>
<select id="selectProjectsFromView" resultType="String">
- SELECT p.uuid FROM projects technical_projects
- INNER JOIN projects p on p.uuid=technical_projects.copy_component_uuid AND p.enabled=${_true}
+ select p.copy_component_uuid
+ from projects p
where
- technical_projects.enabled=${_true}
- AND technical_projects.project_uuid = #{projectViewUuid,jdbcType=VARCHAR}
- AND technical_projects.module_uuid_path LIKE #{viewUuidLikeQuery,jdbcType=VARCHAR}
+ p.enabled = ${_true}
+ and p.project_uuid = #{projectViewUuid,jdbcType=VARCHAR}
+ and p.module_uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR}
+ and p.qualifier = 'TRK'
+ and p.copy_component_uuid is not null
</select>
<select id="selectComponentsFromProjectKeyAndScope" parameterType="map" resultType="Component">