Skip to content
Snippets Groups Projects
Commit 5bb2f0c6 authored by Stan Hu's avatar Stan Hu
Browse files

Add partial index on identities table to speed up LDAP lookups

For customers with thousands of entries in the table, lookups for an
LDAP identity dominated the PostgreSQL statistics because of sequential
scans. We can speed this up by adding a partial index with the
extern_uid and provider.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59630
parent 11f82c89
No related branches found
No related tags found
No related merge requests found
---
title: Add partial index on identities table to speed up LDAP lookups
merge_request: 26710
author:
type: performance
# frozen_string_literal: true
class AddIndexOnIdentitiesLowerExternUidAndProvider < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = "index_on_identities_lower_extern_uid_and_provider"
def up
add_concurrent_index(:identities, 'lower(extern_uid), provider', name: INDEX_NAME)
end
def down
remove_concurrent_index_by_name(:identities, INDEX_NAME)
end
end
Loading
Loading
@@ -1580,6 +1580,7 @@ ActiveRecord::Schema.define(version: 2019_07_29_090456) do
t.datetime "updated_at"
t.integer "saml_provider_id"
t.string "secondary_extern_uid"
t.index "lower((extern_uid)::text), provider", name: "index_on_identities_lower_extern_uid_and_provider"
t.index ["saml_provider_id"], name: "index_identities_on_saml_provider_id", where: "(saml_provider_id IS NOT NULL)"
t.index ["user_id"], name: "index_identities_on_user_id"
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment