diff options
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml | 5 | ||||
-rw-r--r-- | changelogs/unreleased/sh-add-section-name-index.yml | 5 | ||||
-rw-r--r-- | db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb | 21 | ||||
-rw-r--r-- | db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb | 23 | ||||
-rw-r--r-- | db/schema.rb | 5 |
6 files changed, 59 insertions, 2 deletions
@@ -1 +1 @@ -10.6.0-rc1 +10.6.0-rc3 diff --git a/changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml b/changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml new file mode 100644 index 00000000000..d9a1a0db9e8 --- /dev/null +++ b/changelogs/unreleased/sh-add-missing-acts-as-taggable-indices.yml @@ -0,0 +1,5 @@ +--- +title: Adding missing indexes on taggings table +merge_request: +author: +type: performance 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/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb b/db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb new file mode 100644 index 00000000000..06e402adcd7 --- /dev/null +++ b/db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb @@ -0,0 +1,21 @@ +# This migration comes from acts_as_taggable_on_engine (originally 6) +# +# It has been modified to handle no-downtime GitLab migrations. Several +# indexes have been removed since they are not needed for GitLab. +class AddMissingIndexesActsAsTaggableOnEngine < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :taggings, :tag_id unless index_exists? :taggings, :tag_id + add_concurrent_index :taggings, [:taggable_id, :taggable_type] unless index_exists? :taggings, [:taggable_id, :taggable_type] + end + + def down + remove_concurrent_index :taggings, :tag_id + remove_concurrent_index :taggings, [:taggable_id, :taggable_type] + end +end 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..b616cc2fd30 --- /dev/null +++ b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb @@ -0,0 +1,23 @@ +class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + INDEX_NAME = 'index_ci_build_trace_sections_on_section_name_id' + + disable_ddl_transaction! + + def up + # MySQL may already have this as a foreign key + unless index_exists?(:ci_build_trace_sections, :section_name_id, name: INDEX_NAME) + add_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME + 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, name: INDEX_NAME + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b93e6fa594b..bfd4d2ef38f 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: 20180307012445) do +ActiveRecord::Schema.define(version: 20180308052825) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -264,6 +264,7 @@ ActiveRecord::Schema.define(version: 20180307012445) 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" @@ -1733,7 +1734,9 @@ ActiveRecord::Schema.define(version: 20180307012445) do end add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree + add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree + add_index "taggings", ["taggable_id", "taggable_type"], name: "index_taggings_on_taggable_id_and_taggable_type", using: :btree create_table "tags", force: :cascade do |t| t.string "name" |