summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-05 12:10:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-05 12:10:33 +0000
commit023e050d82ed11d9060ce5bdaec99c3871b98164 (patch)
treeee89e2c83c2771c635a0c1daaa88fcce25f18612 /db
parent1c568d834d0cbe1bbbf558ac9a45940f6dbda37a (diff)
downloadgitlab-ce-023e050d82ed11d9060ce5bdaec99c3871b98164.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20210505092746_create_partial_covering_index_for_pending_builds.rb21
-rw-r--r--db/schema_migrations/202105050927461
-rw-r--r--db/structure.sql2
3 files changed, 23 insertions, 1 deletions
diff --git a/db/post_migrate/20210505092746_create_partial_covering_index_for_pending_builds.rb b/db/post_migrate/20210505092746_create_partial_covering_index_for_pending_builds.rb
new file mode 100644
index 00000000000..a1e1dbbeafe
--- /dev/null
+++ b/db/post_migrate/20210505092746_create_partial_covering_index_for_pending_builds.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreatePartialCoveringIndexForPendingBuilds < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ EXISTING_INDEX = 'index_ci_builds_runner_id_pending'
+ NEW_INDEX = 'index_ci_builds_runner_id_pending_covering'
+
+ def up
+ execute "CREATE INDEX CONCURRENTLY #{NEW_INDEX} ON ci_builds (runner_id, id) INCLUDE (project_id) WHERE status = 'pending' AND type = 'Ci::Build'" unless index_exists_by_name?(:ci_builds, NEW_INDEX)
+
+ remove_concurrent_index_by_name :ci_builds, EXISTING_INDEX
+ end
+
+ def down
+ add_concurrent_index :ci_builds, :runner_id, where: "status = 'pending' AND type = 'Ci::Build'", name: EXISTING_INDEX
+ remove_concurrent_index_by_name :ci_builds, NEW_INDEX
+ end
+end
diff --git a/db/schema_migrations/20210505092746 b/db/schema_migrations/20210505092746
new file mode 100644
index 00000000000..b23d8ee3538
--- /dev/null
+++ b/db/schema_migrations/20210505092746
@@ -0,0 +1 @@
+ccf7bce753adabfd7dd8a68fd49853514367f11af42879cae1b6aa28e4ebe94c \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index fce0a085dac..624e74bdd9a 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -22389,7 +22389,7 @@ CREATE INDEX index_ci_builds_on_user_id_and_created_at_and_type_eq_ci_build ON c
CREATE INDEX index_ci_builds_project_id_and_status_for_live_jobs_partial2 ON ci_builds USING btree (project_id, status) WHERE (((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])));
-CREATE INDEX index_ci_builds_runner_id_pending ON ci_builds USING btree (runner_id) WHERE (((status)::text = 'pending'::text) AND ((type)::text = 'Ci::Build'::text));
+CREATE INDEX index_ci_builds_runner_id_pending_covering ON ci_builds USING btree (runner_id, id) INCLUDE (project_id) WHERE (((status)::text = 'pending'::text) AND ((type)::text = 'Ci::Build'::text));
CREATE INDEX index_ci_builds_runner_id_running ON ci_builds USING btree (runner_id) WHERE (((status)::text = 'running'::text) AND ((type)::text = 'Ci::Build'::text));