]> 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:50:28 +0000 (14:50 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 26 Jan 2015 14:04:13 +0000 (15:04 +0100)
server/sonar-server/src/test/java/org/sonar/server/component/persistence/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 4780e00324cfa7c9df5e13a9774f70f71eef74a9..b642dcafc802ba1383628355e7a5f03f6b2cf398 100644 (file)
@@ -219,13 +219,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 416b5c1f1eba2099302a7bf76a4cf4cc68b14988..717f12eddb19b06bb04bb590a8dffe469c9467b0 100644 (file)
@@ -50,7 +50,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>