From: Julien Lancelot Date: Mon, 26 Jan 2015 13:51:49 +0000 (+0100) Subject: SONAR-6063 Performance issue when loading Project Referentials with MS SQL X-Git-Tag: latest-silver-master-#65~77^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f0de650b264f08c766ef992e295b33ed6ab4e4d4;p=sonarqube.git SONAR-6063 Performance issue when loading Project Referentials with MS SQL --- diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java index 742cc8d8da6..e4f6d72109a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java @@ -190,13 +190,14 @@ public class SnapshotDaoTest extends AbstractDaoTestCase { // From root project List 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"); diff --git a/sonar-core/src/main/resources/org/sonar/core/component/db/SnapshotMapper.xml b/sonar-core/src/main/resources/org/sonar/core/component/db/SnapshotMapper.xml index 0aeb697a2c3..06f63965cd9 100644 --- a/sonar-core/src/main/resources/org/sonar/core/component/db/SnapshotMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/component/db/SnapshotMapper.xml @@ -73,10 +73,10 @@ - SELECT + 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} AND s.islast = ${_true} diff --git a/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml b/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml index d86d22e817c..95829b70871 100644 --- a/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml @@ -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 () snapshotModules on snapshotModules.resourceId=prop.resource_id - INNER JOIN projects p on p.id = prop.resource_id WHERE prop.user_id IS NULL