Commit 643bf74c authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '327593-optimize-user-current-highest-access-level' into 'master'

Add partial index on members to optimize highest access level query

See merge request gitlab-org/gitlab!59455
parents 6194c76a c2a19cd4
---
title: Add partial index on members to optimize highest access level query
merge_request: 59455
author:
type: performance
# frozen_string_literal: true
class IndexMembersOnUserIdAccessLevelRequestedAtIsNull < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
INDEX_NAME = 'index_members_on_user_id_and_access_level_requested_at_is_null'
def up
add_concurrent_index(:members, [:user_id, :access_level], where: 'requested_at IS NULL', name: INDEX_NAME)
end
def down
remove_concurrent_index_by_name(:members, INDEX_NAME)
end
end
393a7f1029f05f73c26e031c8980734e13c304846c3457d581c006dc2566d94d
\ No newline at end of file
...@@ -23035,6 +23035,8 @@ CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at) ...@@ -23035,6 +23035,8 @@ CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at)
CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type); CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type);
CREATE INDEX index_members_on_user_id_and_access_level_requested_at_is_null ON members USING btree (user_id, access_level) WHERE (requested_at IS NULL);
CREATE INDEX index_members_on_user_id_created_at ON members USING btree (user_id, created_at) WHERE ((ldap = true) AND ((type)::text = 'GroupMember'::text) AND ((source_type)::text = 'Namespace'::text)); CREATE INDEX index_members_on_user_id_created_at ON members USING btree (user_id, created_at) WHERE ((ldap = true) AND ((type)::text = 'GroupMember'::text) AND ((source_type)::text = 'Namespace'::text));
CREATE INDEX index_members_on_user_id_source_id_source_type ON members USING btree (user_id, source_id, source_type); CREATE INDEX index_members_on_user_id_source_id_source_type ON members USING btree (user_id, source_id, source_type);
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