Commit 75402efb authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '6014-geo-fix-index-for-outdated-projects-on-the-project-repository-states' into 'master'

Resolve "Geo - Revisit the indexes on the project_repository_states table"

Closes #6014

See merge request gitlab-org/gitlab-ee!5986
parents e96f8373 cbc3a3bf
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180531220618) do ActiveRecord::Schema.define(version: 20180605213516) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -2040,8 +2040,8 @@ ActiveRecord::Schema.define(version: 20180531220618) do ...@@ -2040,8 +2040,8 @@ ActiveRecord::Schema.define(version: 20180531220618) do
add_index "project_repository_states", ["last_repository_verification_failure"], name: "idx_repository_states_on_repository_failure_partial", where: "(last_repository_verification_failure IS NOT NULL)", using: :btree add_index "project_repository_states", ["last_repository_verification_failure"], name: "idx_repository_states_on_repository_failure_partial", where: "(last_repository_verification_failure IS NOT NULL)", using: :btree
add_index "project_repository_states", ["last_wiki_verification_failure"], name: "idx_repository_states_on_wiki_failure_partial", where: "(last_wiki_verification_failure IS NOT NULL)", using: :btree add_index "project_repository_states", ["last_wiki_verification_failure"], name: "idx_repository_states_on_wiki_failure_partial", where: "(last_wiki_verification_failure IS NOT NULL)", using: :btree
add_index "project_repository_states", ["project_id"], name: "idx_repository_states_outdated_checksums", where: "(((repository_verification_checksum IS NULL) AND (last_repository_verification_failure IS NULL)) OR ((wiki_verification_checksum IS NULL) AND (last_wiki_verification_failure IS NULL)))", using: :btree
add_index "project_repository_states", ["project_id"], name: "index_project_repository_states_on_project_id", unique: true, using: :btree add_index "project_repository_states", ["project_id"], name: "index_project_repository_states_on_project_id", unique: true, using: :btree
add_index "project_repository_states", ["repository_verification_checksum", "wiki_verification_checksum"], name: "idx_repository_states_on_checksums_partial", where: "((repository_verification_checksum IS NULL) OR (wiki_verification_checksum IS NULL))", using: :btree
create_table "project_statistics", force: :cascade do |t| create_table "project_statistics", force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
......
---
title: Geo - Fix index for outdated projects on the project_repository_states table
merge_request: 5986
author:
type: performance
class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
OLD_INDEX_NAME = 'idx_repository_states_on_checksums_partial'
NEW_INDEX_NAME = 'idx_repository_states_outdated_checksums'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name(:project_repository_states, OLD_INDEX_NAME)
add_concurrent_index(:project_repository_states,
:project_id,
name: NEW_INDEX_NAME,
where: '(repository_verification_checksum IS NULL AND last_repository_verification_failure is NULL) OR (wiki_verification_checksum IS NULL AND last_wiki_verification_failure IS NULL)'
)
end
def down
remove_concurrent_index_by_name(:project_repository_states, NEW_INDEX_NAME)
add_concurrent_index(:project_repository_states,
[:repository_verification_checksum, :wiki_verification_checksum],
name: OLD_INDEX_NAME,
length: Gitlab::Database.mysql? ? 20 : nil,
where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL'
)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment