]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6063 Performance issue when loading Project Referentials with MS SQL
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 26 Jan 2015 13:51:49 +0000 (14:51 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 26 Jan 2015 13:51:49 +0000 (14:51 +0100)
server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java
sonar-core/src/main/resources/org/sonar/core/component/db/SnapshotMapper.xml
sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml

index 742cc8d8da6ac8fda754f8742447ac421d9d39f8..e4f6d72109ad4b9d72b30f9114de51f27791f8b9 100644 (file)
@@ -190,13 +190,14 @@ public class SnapshotDaoTest extends AbstractDaoTestCase {
     // From root project
     List<SnapshotDto> snapshots = sut.findChildrenModulesFromModule(session, "org.struts:struts");
     assertThat(snapshots).hasSize(2);
-    assertThat(snapshots).onProperty("id").containsOnly(2L, 3L);
-    assertThat(snapshots).onProperty("last").containsOnly(true);
+    assertThat(snapshots).onProperty("resourceId").containsOnly(2L, 3L);
+    assertThat(snapshots).onProperty("parentId").containsOnly(1L, 2L);
 
     // From module
     snapshots = sut.findChildrenModulesFromModule(session, "org.struts:struts-core");
     assertThat(snapshots).hasSize(1);
-    assertThat(snapshots).onProperty("id").containsOnly(3L);
+    assertThat(snapshots).onProperty("resourceId").containsOnly(3L);
+    assertThat(snapshots).onProperty("parentId").containsOnly(2L);
 
     // From sub module
     snapshots = sut.findChildrenModulesFromModule(session, "org.struts:struts-data");
index 0aeb697a2c32170c3d59ece7dd23e1a58fc198d3..06f63965cd9891cf4dacaa03cffe2ec2d8de8c39 100644 (file)
   </select>
 
   <sql id="selectChildrenModulesFromModuleQuery">
-    SELECT <include refid="org.sonar.core.component.db.SnapshotMapper.snapshotColumns"/>
+    SELECT s.project_id as resourceId, s.parent_snapshot_id as parentId
     FROM snapshots s
     INNER JOIN snapshots root_snapshot ON root_snapshot.id = s.root_snapshot_id AND root_snapshot.islast = ${_true}
-    INNER JOIN snapshots current_snapshot ON current_snapshot.root_project_id = root_snapshot.project_id AND s.islast = ${_true}
+    INNER JOIN snapshots current_snapshot ON current_snapshot.root_project_id = root_snapshot.project_id AND current_snapshot.islast = ${_true}
     INNER JOIN projects module ON module.id = current_snapshot.project_id AND module.enabled = ${_true} AND module.kee = #{moduleKey}
     <where>
       AND s.islast = ${_true}
index d86d22e817cafd5c4975f0802c1c6477847f45f6..95829b708715655b3dcc01bea303cd5e2379dd52 100644 (file)
@@ -49,7 +49,6 @@
     SELECT prop.id as id, prop.prop_key as "key", prop.text_value as value, prop.resource_id as resourceId, prop.user_id as userId
     FROM properties prop
     INNER JOIN (<include refid="org.sonar.core.component.db.SnapshotMapper.selectChildrenModulesFromModuleQuery" />) snapshotModules on snapshotModules.resourceId=prop.resource_id
-    INNER JOIN projects p on p.id = prop.resource_id
     WHERE prop.user_id IS NULL
   </select>