Commit f3a8bd29 authored by Robert Hunt's avatar Robert Hunt Committed by Toon Claes

Added new index to audit_events table

Added a new index to the audit_events table to allow us to be
performant when querying for author_id in relation to the entity_id,
entity_type and id

Updated structure.sql with the new migration
parent 333db852
# frozen_string_literal: true
class AddAuthorIdIndexToAuditEvents < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_on_author_id_and_entity_id_and_entity_type_and_id_desc'.freeze
def up
add_concurrent_index(:audit_events, [:author_id, :entity_id, :entity_type, :id], order: { id: :desc }, name: INDEX_NAME)
end
def down
remove_concurrent_index_by_name(:audit_events, INDEX_NAME)
end
end
......@@ -10469,6 +10469,8 @@ CREATE UNIQUE INDEX index_oauth_applications_on_uid ON public.oauth_applications
CREATE INDEX index_oauth_openid_requests_on_access_grant_id ON public.oauth_openid_requests USING btree (access_grant_id);
CREATE INDEX index_on_author_id_and_entity_id_and_entity_type_and_id_desc ON public.audit_events USING btree (author_id, entity_id, entity_type, id DESC);
CREATE UNIQUE INDEX index_on_deploy_keys_id_and_type_and_public ON public.keys USING btree (id, type) WHERE (public = true);
CREATE INDEX index_on_id_partial_with_legacy_storage ON public.projects USING btree (id) WHERE ((storage_version < 2) OR (storage_version IS NULL));
......@@ -14108,6 +14110,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200615123055
20200615193524
20200615232735
20200616145031
20200617000757
20200617001001
20200617001118
......
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