Add index for ci_commits for gl_project_id, ref, status

and remove the old one which we don't really need.
This commit is contained in:
Lin Jen-Shin 2017-02-16 22:19:24 +08:00
parent 3750b06b8c
commit 22d6f96cf9
3 changed files with 20 additions and 2 deletions

View File

@ -0,0 +1,10 @@
class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def change
add_concurrent_index(:ci_commits, [:gl_project_id, :ref, :status])
end
end

View File

@ -0,0 +1,8 @@
class DropIndexForBuildsProjectStatus < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
remove_index(:ci_commits, [:gl_project_id, :status])
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170215200045) do
ActiveRecord::Schema.define(version: 20170216141440) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -251,8 +251,8 @@ ActiveRecord::Schema.define(version: 20170215200045) do
t.integer "lock_version"
end
add_index "ci_commits", ["gl_project_id", "ref", "status"], name: "index_ci_commits_on_gl_project_id_and_ref_and_status", using: :btree
add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree
add_index "ci_commits", ["gl_project_id", "status"], name: "index_ci_commits_on_gl_project_id_and_status", using: :btree
add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree
add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree
add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree