summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-01-21 13:44:25 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2017-01-21 13:44:25 +0100
commite447ea63a49b1f28975fc9678fe92a679a34455b (patch)
treed3aac8283160886f9f8e0a9988172f92719ca762 /db/migrate
parent491f1375fc055805c623a3079a383de988689f3d (diff)
downloadgitlab-ce-e447ea63a49b1f28975fc9678fe92a679a34455b.tar.gz
Add index for ci_builds that makes shared runners query to run 50x faster.
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb b/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb
new file mode 100644
index 00000000000..4ea953f2b78
--- /dev/null
+++ b/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb
@@ -0,0 +1,17 @@
+class AddIndexToCiBuildsForStatusRunnerIdAndType < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_builds, [:status, :type, :runner_id]
+ end
+
+ def down
+ if index_exists?(:ci_builds, [:status, :type, :runner_id])
+ remove_index :ci_builds, column: [:status, :type, :runner_id]
+ end
+ end
+end