diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-08-06 13:39:35 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-08-06 13:39:35 +0000 |
commit | 4c1a5ba822109582d85a19ac4ce7e99e5cfa9641 (patch) | |
tree | db3cb210ca38109fe84411bccc9ff29211e58610 /db | |
parent | 26087322713e2949f2bf207798512374757a484c (diff) | |
parent | 743497aa0502781072b84eb51c2663180813b5c6 (diff) | |
download | gitlab-ce-4c1a5ba822109582d85a19ac4ce7e99e5cfa9641.tar.gz |
Merge branch '43080-speed-up-deploy-keys' into 'master'
Improve the performance of viewing deploy keys
Closes #43080
See merge request gitlab-org/gitlab-ce!31384
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20190802235445_add_index_on_id_and_type_and_public_to_keys.rb | 23 | ||||
-rw-r--r-- | db/schema.rb | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/db/post_migrate/20190802235445_add_index_on_id_and_type_and_public_to_keys.rb b/db/post_migrate/20190802235445_add_index_on_id_and_type_and_public_to_keys.rb new file mode 100644 index 00000000000..9b4d74b4bea --- /dev/null +++ b/db/post_migrate/20190802235445_add_index_on_id_and_type_and_public_to_keys.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddIndexOnIdAndTypeAndPublicToKeys < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + INDEX_NAME = "index_on_deploy_keys_id_and_type_and_public" + + def up + add_concurrent_index(:keys, + [:id, :type], + where: "public = 't'", + unique: true, + name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(:keys, INDEX_NAME) + end +end diff --git a/db/schema.rb b/db/schema.rb index 90d93ddc736..8d5da4a07dd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_08_02_012622) do +ActiveRecord::Schema.define(version: 2019_08_02_235445) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -1770,6 +1770,7 @@ ActiveRecord::Schema.define(version: 2019_08_02_012622) do t.boolean "public", default: false, null: false t.datetime "last_used_at" t.index ["fingerprint"], name: "index_keys_on_fingerprint", unique: true + t.index ["id", "type"], name: "index_on_deploy_keys_id_and_type_and_public", unique: true, where: "(public = true)" t.index ["user_id"], name: "index_keys_on_user_id" end |