summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-03-08 12:53:23 +0000
committerIan Baum <ibaum@gitlab.com>2018-03-15 13:13:01 -0500
commit3641b68686fb57927bf1db93360356f02090231f (patch)
treedda653cfc1c9f689d1f9cd43dd52a4ea3b528108
parentc0cd02ea350962c25413ae3153138d4cfc837475 (diff)
downloadgitlab-ce-3641b68686fb57927bf1db93360356f02090231f.tar.gz
Merge branch 'sh-add-section-name-index' into 'master'
Add index on section_name_id on ci_build_trace_sections table Closes #44008 See merge request gitlab-org/gitlab-ce!17632
-rw-r--r--changelogs/unreleased/sh-add-section-name-index.yml5
-rw-r--r--db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb22
-rw-r--r--db/schema.rb3
3 files changed, 29 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-add-section-name-index.yml b/changelogs/unreleased/sh-add-section-name-index.yml
new file mode 100644
index 00000000000..c822b4e851b
--- /dev/null
+++ b/changelogs/unreleased/sh-add-section-name-index.yml
@@ -0,0 +1,5 @@
+---
+title: Add index on section_name_id on ci_build_trace_sections table
+merge_request:
+author:
+type: performance
diff --git a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
new file mode 100644
index 00000000000..0cf665ac935
--- /dev/null
+++ b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
@@ -0,0 +1,22 @@
+class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # MySQL may already have this as a foreign key
+ unless index_exists?(:ci_build_trace_sections, :section_name_id)
+ add_concurrent_index :ci_build_trace_sections, :section_name_id
+ end
+ end
+
+ def down
+ # We cannot remove index for MySQL because it's needed for foreign key
+ if Gitlab::Database.postgresql?
+ remove_concurrent_index :ci_build_trace_sections, :section_name_id
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5bb461169f1..ee3fe52b0be 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: 20180216121030) do
+ActiveRecord::Schema.define(version: 20180308052825) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -249,6 +249,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do
add_index "ci_build_trace_sections", ["build_id", "section_name_id"], name: "index_ci_build_trace_sections_on_build_id_and_section_name_id", unique: true, using: :btree
add_index "ci_build_trace_sections", ["project_id"], name: "index_ci_build_trace_sections_on_project_id", using: :btree
+ add_index "ci_build_trace_sections", ["section_name_id"], name: "index_ci_build_trace_sections_on_section_name_id", using: :btree
create_table "ci_builds", force: :cascade do |t|
t.string "status"