Improve projects indexes

This commit is contained in:
Valery Sizov 2018-07-16 18:43:34 +03:00
parent 2c5e6b272e
commit 125215f2f1
3 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
title: Rework some projects table indexes around repository_storage field
merge_request: 20377
author:
type: fixed

View file

@ -0,0 +1,23 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class UpdateProjectIndexes < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
NEW_INDEX_NAME = 'idx_project_repository_check_partial'
disable_ddl_transaction!
def up
add_concurrent_index(:projects,
[:repository_storage, :created_at],
name: NEW_INDEX_NAME,
where: 'last_repository_check_at IS NULL'
)
end
def down
remove_concurrent_index_by_name(:projects, NEW_INDEX_NAME)
end
end

View file

@ -1674,6 +1674,7 @@ ActiveRecord::Schema.define(version: 20180704204006) do
add_index "projects", ["path"], name: "index_projects_on_path", using: :btree
add_index "projects", ["path"], name: "index_projects_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"}
add_index "projects", ["pending_delete"], name: "index_projects_on_pending_delete", using: :btree
add_index "projects", ["repository_storage", "created_at"], name: "idx_project_repository_check_partial", where: "(last_repository_check_at IS NULL)", using: :btree
add_index "projects", ["repository_storage"], name: "index_projects_on_repository_storage", using: :btree
add_index "projects", ["runners_token"], name: "index_projects_on_runners_token", using: :btree
add_index "projects", ["star_count"], name: "index_projects_on_star_count", using: :btree