Commit a9e19e07 authored by Toon Claes's avatar Toon Claes

Merge branch '208234-optimize-ldap-keys-in-usage-data' into 'master'

Optimize ldap_keys count in usage_data

Closes #211474

See merge request gitlab-org/gitlab!27309
parents ef4a021f 27f5297f
---
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], where: "type = 'LDAPKey'", name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :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"
......@@ -2311,6 +2311,7 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
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_on_deploy_keys_id_and_type_and_public", unique: true, where: "(public = true)"
t.index ["id"], name: "index_keys_on_id_and_ldap_key_type", where: "((type)::text = 'LDAPKey'::text)"
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"
end
......
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