diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-05 20:53:44 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-10-05 20:53:44 +0900 |
commit | 4b2f21dfaffed2960a70d2f242d3d7c8da2b92f1 (patch) | |
tree | 582eb1e4b840aeb157b0abf796e11da95a971662 /db | |
parent | ada45a7496971656af180f1790d61d75806361d2 (diff) | |
download | gitlab-ce-4b2f21dfaffed2960a70d2f242d3d7c8da2b92f1.tar.gz |
Change partial index's condition to make stale delayed builds removal a lot faster
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb | 2 | ||||
-rw-r--r-- | db/schema.rb | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb index c2e62dede8a..81bf0d94e11 100644 --- a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb +++ b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb @@ -9,7 +9,7 @@ class AddPartialIndexToScheduledAt < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index(:ci_builds, [:scheduled_at, :id], where: "scheduled_at IS NOT NULL", name: INDEX_NAME) + add_concurrent_index(:ci_builds, :scheduled_at, where: "scheduled_at IS NOT NULL AND type = 'Ci::Build' AND status = 'scheduled'", name: INDEX_NAME) end def down diff --git a/db/schema.rb b/db/schema.rb index f14859d9eac..2e5d5ed1f3b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -347,7 +347,7 @@ ActiveRecord::Schema.define(version: 20180924201039) do add_index "ci_builds", ["project_id", "id"], name: "index_ci_builds_on_project_id_and_id", using: :btree add_index "ci_builds", ["protected"], name: "index_ci_builds_on_protected", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree - add_index "ci_builds", ["scheduled_at", "id"], name: "partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs", where: "(scheduled_at IS NOT NULL)", using: :btree + add_index "ci_builds", ["scheduled_at"], name: "partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs", where: "((scheduled_at IS NOT NULL) AND ((type)::text = 'Ci::Build'::text) AND ((status)::text = 'scheduled'::text))", using: :btree add_index "ci_builds", ["stage_id", "stage_idx"], name: "tmp_build_stage_position_index", where: "(stage_idx IS NOT NULL)", using: :btree add_index "ci_builds", ["stage_id"], name: "index_ci_builds_on_stage_id", using: :btree add_index "ci_builds", ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree @@ -2290,6 +2290,7 @@ ActiveRecord::Schema.define(version: 20180924201039) do add_foreign_key "boards", "namespaces", column: "group_id", on_delete: :cascade add_foreign_key "boards", "projects", name: "fk_f15266b5f9", on_delete: :cascade add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "ci_build_schedules", "ci_builds", column: "build_id", on_delete: :cascade add_foreign_key "ci_build_trace_chunks", "ci_builds", column: "build_id", on_delete: :cascade add_foreign_key "ci_build_trace_section_names", "projects", on_delete: :cascade add_foreign_key "ci_build_trace_sections", "ci_build_trace_section_names", column: "section_name_id", name: "fk_264e112c66", on_delete: :cascade |