Commit 6333bc66 authored by Arturo Herrero's avatar Arturo Herrero

Update index on namespaces for type and id

Including the id column in the partial index improves performance.
parent 163ad707
---
title: Update database index on namespaces for type and id
merge_request: 42128
author:
type: other
# frozen_string_literal: true
class UpdateIndexOnNamespacesForTypeAndId < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
OLD_INDEX_NAME = 'index_namespaces_on_type_partial'
NEW_INDEX_NAME = 'index_namespaces_on_type_and_id_partial'
def up
add_concurrent_index(:namespaces, [:type, :id], where: 'type IS NOT NULL', name: NEW_INDEX_NAME)
remove_concurrent_index_by_name(:namespaces, OLD_INDEX_NAME)
end
def down
add_concurrent_index(:namespaces, :type, where: 'type IS NOT NULL', name: OLD_INDEX_NAME)
remove_concurrent_index_by_name(:namespaces, NEW_INDEX_NAME)
end
end
0080b9192ba5b4ea3853cfd930d58e10b9619f3d9a54016b574712e5ec2084f6
\ No newline at end of file
......@@ -20596,7 +20596,7 @@ CREATE UNIQUE INDEX index_namespaces_on_runners_token_encrypted ON namespaces US
CREATE INDEX index_namespaces_on_shared_and_extra_runners_minutes_limit ON namespaces USING btree (shared_runners_minutes_limit, extra_shared_runners_minutes_limit);
CREATE INDEX index_namespaces_on_type_partial ON namespaces USING btree (type) WHERE (type IS NOT NULL);
CREATE INDEX index_namespaces_on_type_and_id_partial ON namespaces USING btree (type, id) WHERE (type IS NOT NULL);
CREATE INDEX index_non_requested_project_members_on_source_id_and_type ON members USING btree (source_id, source_type) WHERE ((requested_at IS NULL) AND ((type)::text = 'ProjectMember'::text));
......
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