diff options
-rw-r--r-- | changelogs/unreleased/sh-add-ci-build-indexes.yml | 4 | ||||
-rw-r--r-- | db/migrate/20170216091009_add_index_to_ci_builds_for_project_status_and_type.rb | 11 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 17 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-add-ci-build-indexes.yml b/changelogs/unreleased/sh-add-ci-build-indexes.yml new file mode 100644 index 00000000000..d498c978f4d --- /dev/null +++ b/changelogs/unreleased/sh-add-ci-build-indexes.yml @@ -0,0 +1,4 @@ +--- +title: Add index for slow queries in BuildsController#index +merge_request: +author: diff --git a/db/migrate/20170216091009_add_index_to_ci_builds_for_project_status_and_type.rb b/db/migrate/20170216091009_add_index_to_ci_builds_for_project_status_and_type.rb new file mode 100644 index 00000000000..1a074b596a9 --- /dev/null +++ b/db/migrate/20170216091009_add_index_to_ci_builds_for_project_status_and_type.rb @@ -0,0 +1,11 @@ +class AddIndexToCiBuildsForProjectStatusAndType < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_concurrent_index :ci_builds, [:project_id, :status, :type] + end +end diff --git a/db/schema.rb b/db/schema.rb index 52672406ec6..604cfe2f90f 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: 20170214111112) do +ActiveRecord::Schema.define(version: 20170216091009) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -225,6 +225,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree add_index "ci_builds", ["gl_project_id"], name: "index_ci_builds_on_gl_project_id", using: :btree + add_index "ci_builds", ["project_id", "status", "type"], name: "index_ci_builds_on_project_id_and_status_and_type", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree add_index "ci_builds", ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree |