Add database index on patch_sets.revision
Without that index the PatchSetAccess.byRevision was always doing a sequential table scan. Change-Id: Ief351d56794589fa0e1804fac5a6c38fea67e23c
This commit is contained in:
parent
2b29b43b97
commit
2fabd1ab29
@ -100,6 +100,11 @@ CREATE INDEX patch_comment_drafts
|
||||
ON patch_comments (status, author_id);
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAccess
|
||||
CREATE INDEX patch_sets_byRevision
|
||||
ON patch_sets (revision);
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAncestorAccess
|
||||
-- @PrimaryKey covers: ancestorsOf
|
||||
|
@ -151,6 +151,11 @@ ON patch_comments (author_id)
|
||||
WHERE status = 'd';
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAccess
|
||||
CREATE INDEX patch_sets_byRevision
|
||||
ON patch_sets (revision);
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAncestorAccess
|
||||
-- @PrimaryKey covers: ancestorsOf
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
public static final Class<Schema_93> C = Schema_93.class;
|
||||
public static final Class<Schema_94> C = Schema_94.class;
|
||||
|
||||
public static class Module extends AbstractModule {
|
||||
@Override
|
||||
|
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gwtorm.jdbc.JdbcSchema;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class Schema_94 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_94(Provider<Schema_93> prior) {
|
||||
super(prior);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
|
||||
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement()) {
|
||||
stmt.execute("CREATE INDEX patch_sets_byRevision"
|
||||
+ " ON patch_sets (revision)");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user