From 764185d9211229e5dcafe885cfdcbfbfadf54ce7 Mon Sep 17 00:00:00 2001 From: Eric Hartmann Date: Wed, 14 Jun 2017 13:24:39 +0200 Subject: [PATCH] SONAR-9427 Improve performance on quality profile changelog --- .../org/sonar/db/version/schema-h2.ddl | 4 +- .../qualityprofile/QProfileChangeMapper.xml | 10 +- .../qualityprofile/QProfileChangeDaoTest.java | 2 +- .../db/migration/def/TinyIntColumnDef.java | 2 + .../db/migration/def/Validations.java | 3 +- .../db/migration/sql/AlterColumnsBuilder.java | 2 - .../migration/sql/RenameColumnsBuilder.java | 132 ++++++++++++++ ...ProfileUuidOnQProfileChangesIsIndexed.java | 54 ++++++ .../db/migration/version/v65/DbVersion65.java | 4 +- ...eyToRulesProfileUuidOnQProfileChanges.java | 51 ++++++ .../sql/RenameColumnsBuilderTest.java | 167 ++++++++++++++++++ ...ileUuidOnQProfileChangesIsIndexedTest.java | 44 +++++ .../version/v65/DbVersion65Test.java | 2 +- ...RulesProfileUuidOnQProfileChangesTest.java | 45 +++++ .../initial.sql | 9 + .../initial.sql | 9 + .../qualityprofile/QProfileFactoryTest.java | 4 +- 17 files changed, 529 insertions(+), 15 deletions(-) create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/RenameColumnsBuilder.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexed.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/RenameColumnsBuilderTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest.java create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest/initial.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest/initial.sql diff --git a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl index a63c0dde526..b561d120bec 100644 --- a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -542,13 +542,13 @@ CREATE TABLE "PERM_TEMPLATES_GROUPS" ( CREATE TABLE "QPROFILE_CHANGES" ( "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "QPROFILE_KEY" VARCHAR(255) NOT NULL, + "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, "CHANGE_TYPE" VARCHAR(20) NOT NULL, "CREATED_AT" BIGINT NOT NULL, "USER_LOGIN" VARCHAR(255), "CHANGE_DATA" CLOB ); -CREATE INDEX "QPROFILE_CHANGES_QPROFILE_KEY" ON "QPROFILE_CHANGES" ("QPROFILE_KEY"); +CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES" ("RULES_PROFILE_UUID"); CREATE TABLE "FILE_SOURCES" ( diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileChangeMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileChangeMapper.xml index 77ebd8602b8..172b7c9a8ea 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileChangeMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileChangeMapper.xml @@ -5,7 +5,7 @@ qpc.kee as "uuid", - qpc.qprofile_key as rulesProfileUuid, + qpc.rules_profile_uuid as rulesProfileUuid, qpc.created_at as createdAt, qpc.user_login as login, qpc.change_type as changeType, @@ -16,7 +16,7 @@ insert into qprofile_changes ( kee, - qprofile_key, + rules_profile_uuid, created_at, user_login, change_type, @@ -34,7 +34,7 @@