]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9909 Slow indexing of portfolios at server startup
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 4 Oct 2017 10:38:39 +0000 (12:38 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 4 Oct 2017 15:23:23 +0000 (17:23 +0200)
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.

server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml

index d35ba1ef4d6e269a82c895016057793e634f27d6..0a4b557880ced386309418a8500d7280d48597f1 100644 (file)
   </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">