diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-18 13:02:38 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-18 13:02:38 +0000 |
commit | d81189029d072b41434992efb991152842639009 (patch) | |
tree | 18ea2deddf74ffab2f5d0423f55413590f931d71 | |
parent | 740ae2d194f3833e224c326cc909d833c5807484 (diff) | |
parent | 125215f2f1374b060bac42397dce48298689f162 (diff) | |
download | gitlab-ce-d81189029d072b41434992efb991152842639009.tar.gz |
Merge branch '4525-fix-project-indexes' into 'master'
Improve projects indexes
See merge request gitlab-org/gitlab-ce!20377
-rw-r--r-- | changelogs/unreleased/4525-fix-project-indexes.yml | 5 | ||||
-rw-r--r-- | db/post_migrate/20180704145007_update_project_indexes.rb | 23 | ||||
-rw-r--r-- | db/schema.rb | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/changelogs/unreleased/4525-fix-project-indexes.yml b/changelogs/unreleased/4525-fix-project-indexes.yml new file mode 100644 index 00000000000..930e3b934c2 --- /dev/null +++ b/changelogs/unreleased/4525-fix-project-indexes.yml @@ -0,0 +1,5 @@ +--- +title: Rework some projects table indexes around repository_storage field +merge_request: 20377 +author: +type: fixed diff --git a/db/post_migrate/20180704145007_update_project_indexes.rb b/db/post_migrate/20180704145007_update_project_indexes.rb new file mode 100644 index 00000000000..193563b36db --- /dev/null +++ b/db/post_migrate/20180704145007_update_project_indexes.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index d2aa31fae30..1a5555fb3a4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 |