From: Jean-Baptiste Vilain Date: Tue, 6 Aug 2013 09:36:02 +0000 (+0200) Subject: SONAR-4529 Add index on created_at column of notifications table to improve notificat... X-Git-Tag: 3.7.1-RC1-~158 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea6fa01e6516f15e31261230abbf63e7ceed3dab;p=sonarqube.git SONAR-4529 Add index on created_at column of notifications table to improve notifications performance --- diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index c59df69feb3..dc0382384d3 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -33,7 +33,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 419; + public static final int LAST_VERSION = 430; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 98231f3ff1d..29c4e615445 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -172,6 +172,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('416'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('417'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('418'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('419'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('430'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index b450b85b834..ad2fdc11ed7 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -694,3 +694,5 @@ CREATE INDEX "SNAPSHOTS_ROOT_PROJECT_ID" ON "SNAPSHOTS" ("ROOT_PROJECT_ID"); CREATE INDEX "GROUP_ROLES_ROLE" ON "GROUP_ROLES" ("ROLE"); CREATE UNIQUE INDEX "RULES_PLUGIN_KEY_AND_NAME" ON "RULES" ("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE INDEX "NOTIFICATIONS_CREATED_AT" ON "NOTIFICATIONS" ("CREATED_AT"); diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/430_add_index_to_notifications_created_at.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/430_add_index_to_notifications_created_at.rb new file mode 100644 index 00000000000..d9d155fb408 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/430_add_index_to_notifications_created_at.rb @@ -0,0 +1,34 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2013 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# @since SonarQube 4.0 +# +class AddIndexToNotificationsCreatedAt < ActiveRecord::Migration + + def self.up + begin + add_index :notifications, :created_at, :name => 'notifications_created_at' + rescue + # already exists + end + end + +end