Commit b3bda708 authored by alinamihaila's avatar alinamihaila

Optimize ldap keys counters query performance for usage data

parent 015cfbc7
---
title: Optimize ldap keys counters query performance in usage data
merge_request: 27309
author:
type: performance
# frozen_string_literal: true
class AddIndexOnIdAndLdapKeyToKeys < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_keys_on_id_and_ldap_key_type'
disable_ddl_transaction!
def up
add_concurrent_index :keys, [:id, :type], where: "type = 'LDAPKey'", name: INDEX_NAME
end
def down
remove_concurrent_index :keys, INDEX_NAME
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_03_13_123934) do
ActiveRecord::Schema.define(version: 2020_03_16_111759) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
......@@ -2309,6 +2309,7 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
t.datetime_with_timezone "expires_at"
t.index ["fingerprint"], name: "index_keys_on_fingerprint", unique: true
t.index ["fingerprint_sha256"], name: "index_keys_on_fingerprint_sha256"
t.index ["id", "type"], name: "index_keys_on_id_and_ldap_key_type", where: "((type)::text = 'LDAPKey'::text)"
t.index ["id", "type"], name: "index_on_deploy_keys_id_and_type_and_public", unique: true, where: "(public = true)"
t.index ["last_used_at"], name: "index_keys_on_last_used_at", order: "DESC NULLS LAST"
t.index ["user_id"], name: "index_keys_on_user_id"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment