Commit 7bc572bf authored by Andreas Brandl's avatar Andreas Brandl

Merge branch '1449-add-created-at-index-on-audit-events' into 'master'

Optimise index on audit events for CSV export

See merge request gitlab-org/gitlab!41266
parents 4b671392 fbcf3b78
---
title: Optimise index on audit events for CSV export
merge_request: 41266
author:
type: added
# frozen_string_literal: true
class AddCreatedAtIndexToAuditEvents < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'idx_audit_events_on_entity_id_desc_author_id_created_at'
OLD_INDEX_NAME = 'index_audit_events_on_entity_id_entity_type_id_desc_author_id'
def up
add_concurrent_index(:audit_events, [:entity_id, :entity_type, :id, :author_id, :created_at], order: { id: :desc }, name: INDEX_NAME)
remove_concurrent_index_by_name(:audit_events, OLD_INDEX_NAME)
end
def down
add_concurrent_index(:audit_events, [:entity_id, :entity_type, :id, :author_id], order: { id: :desc }, name: OLD_INDEX_NAME)
remove_concurrent_index_by_name(:audit_events, INDEX_NAME)
end
end
5c065dc7905fd1292e270d2248810d71fa71d6b6996e9d60c463a7eb36042881
\ No newline at end of file
......@@ -19075,6 +19075,8 @@ CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_and_note_id_index ON public.ep
CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_index ON public.epic_user_mentions USING btree (epic_id) WHERE (note_id IS NULL);
CREATE INDEX idx_audit_events_on_entity_id_desc_author_id_created_at ON public.audit_events USING btree (entity_id, entity_type, id DESC, author_id, created_at);
CREATE INDEX idx_ci_pipelines_artifacts_locked ON public.ci_pipelines USING btree (ci_ref_id, id) WHERE (locked = 1);
CREATE INDEX idx_container_scanning_findings ON public.vulnerability_occurrences USING btree (id) WHERE (report_type = 2);
......@@ -19267,8 +19269,6 @@ CREATE INDEX index_approvers_on_user_id ON public.approvers USING btree (user_id
CREATE UNIQUE INDEX index_atlassian_identities_on_extern_uid ON public.atlassian_identities USING btree (extern_uid);
CREATE INDEX index_audit_events_on_entity_id_entity_type_id_desc_author_id ON public.audit_events USING btree (entity_id, entity_type, id DESC, author_id);
CREATE INDEX index_award_emoji_on_awardable_type_and_awardable_id ON public.award_emoji USING btree (awardable_type, awardable_id);
CREATE INDEX index_award_emoji_on_user_id_and_name ON public.award_emoji USING btree (user_id, name);
......
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