summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-06-12 20:29:29 +0200
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-06-12 20:29:29 +0200
commitd7c6e414c6079a1242922ca0c1ba6500809c131d (patch)
tree587e50c17a5a81ef72958ec6071dd8325536f0b4
parent9cb3510aed0a758045d26fac3c3610a1496eb5a2 (diff)
downloadgitlab-ce-zj-index-created-at-ci-build.tar.gz
Add index to ci_builds for created_at and projectzj-index-created-at-ci-build
This should improve performance while fetching the needed jobs for the pipeline charts.
-rw-r--r--changelogs/unreleased/zj-index-created-at-ci-build.yml4
-rw-r--r--db/migrate/20170612180416_add_index_created_at_ci_builds.rb16
-rw-r--r--db/schema.rb4
3 files changed, 23 insertions, 1 deletions
diff --git a/changelogs/unreleased/zj-index-created-at-ci-build.yml b/changelogs/unreleased/zj-index-created-at-ci-build.yml
new file mode 100644
index 00000000000..c4eee464f3e
--- /dev/null
+++ b/changelogs/unreleased/zj-index-created-at-ci-build.yml
@@ -0,0 +1,4 @@
+---
+title: Improve performance on pipeline charts
+merge_request:
+author:
diff --git a/db/migrate/20170612180416_add_index_created_at_ci_builds.rb b/db/migrate/20170612180416_add_index_created_at_ci_builds.rb
new file mode 100644
index 00000000000..fae0539da90
--- /dev/null
+++ b/db/migrate/20170612180416_add_index_created_at_ci_builds.rb
@@ -0,0 +1,16 @@
+class AddIndexCreatedAtCiBuilds < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_builds, [:project_id, :created_at]
+ end
+
+ def down
+ if index_exists? :ci_builds, [:project_id, :created_at]
+ remove_concurrent_index :ci_builds, [:project_id, :created_at]
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b93630a410d..93a3a68bffb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,8 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170606202615) do
+ActiveRecord::Schema.define(version: 20170612180416) do
+
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "pg_trgm"
@@ -241,6 +242,7 @@ ActiveRecord::Schema.define(version: 20170606202615) do
add_index "ci_builds", ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree
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", ["project_id", "created_at"], name: "index_ci_builds_on_project_id_and_created_at", 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", ["stage_id"], name: "index_ci_builds_on_stage_id", using: :btree