diff options
author | Stan Hu <stanhu@gmail.com> | 2017-02-10 11:01:23 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-02-10 18:51:48 +0300 |
commit | 41d7b47c3cd3357269f967548428a768a606f0f0 (patch) | |
tree | a03ee968e503c6f3646e0f423f3317bb21a700c3 | |
parent | b88e82ff0a1bca9687b5579208ba05a99e41a464 (diff) |
Add index to ci_trigger_requests for commit_id
https://gitlab.com/gitlab-org/gitlab-ce/pipelines.json makes
a number of unindexed slow queries. This index should
speed things up.
-rw-r--r-- | changelogs/unreleased/sh-add-index-to-ci-trigger-requests.yml | 4 | ||||
-rw-r--r-- | db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb | 11 | ||||
-rw-r--r-- | db/schema.rb | 4 |
3 files changed, 18 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-add-index-to-ci-trigger-requests.yml b/changelogs/unreleased/sh-add-index-to-ci-trigger-requests.yml new file mode 100644 index 00000000000..bab76812a17 --- /dev/null +++ b/changelogs/unreleased/sh-add-index-to-ci-trigger-requests.yml @@ -0,0 +1,4 @@ +--- +title: Add index to ci_trigger_requests for commit_id +merge_request: +author: diff --git a/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb b/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb new file mode 100644 index 00000000000..61e49c14fc0 --- /dev/null +++ b/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb @@ -0,0 +1,11 @@ +class AddIndexToCiTriggerRequestsForCommitId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_concurrent_index :ci_trigger_requests, :commit_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 3fef5b82073..d71911eaf14 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170206101030) do +ActiveRecord::Schema.define(version: 20170210075922) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -367,6 +367,8 @@ ActiveRecord::Schema.define(version: 20170206101030) do t.integer "commit_id" end + add_index "ci_trigger_requests", ["commit_id"], name: "index_ci_trigger_requests_on_commit_id", using: :btree + create_table "ci_triggers", force: :cascade do |t| t.string "token" t.integer "project_id" |