Merge branch 'sh-add-index-extern-uid' into 'master'

Add partial index on identities table to speed up LDAP lookups

Closes #59630

See merge request gitlab-org/gitlab-ce!26710
This commit is contained in:
Douglas Barbosa Alexandre 2019-07-30 17:13:16 +00:00
commit d1c71c7c54
3 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
title: Add partial index on identities table to speed up LDAP lookups
merge_request: 26710
author:
type: performance

View file

@ -0,0 +1,19 @@
# 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

View file

@ -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