Commit 57c6beeb authored by Toon Claes's avatar Toon Claes

Merge branch '39474-unable-to-view-project-audit-events-statement-timeouts' into 'master'

Resolve "Unable to view project audit events: statement timeouts"

See merge request gitlab-org/gitlab!23998
parents 8686325f 6947dd1a
---
title: Add index to audit_events (entity_id, entity_type, id)
merge_request: 23998
author:
type: performance
# frozen_string_literal: true
class AddIndexOnAuditEventsIdDesc < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
OLD_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type'
NEW_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type_and_id_desc'
disable_ddl_transaction!
def up
add_concurrent_index :audit_events, [:entity_id, :entity_type, :id], name: NEW_INDEX_NAME,
order: { entity_id: :asc, entity_type: :asc, id: :desc }
remove_concurrent_index_by_name :audit_events, OLD_INDEX_NAME
end
def down
add_concurrent_index :audit_events, [:entity_id, :entity_type], name: OLD_INDEX_NAME
remove_concurrent_index_by_name :audit_events, NEW_INDEX_NAME
end
end
...@@ -465,7 +465,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do ...@@ -465,7 +465,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.index ["created_at", "author_id"], name: "analytics_index_audit_events_on_created_at_and_author_id" t.index ["created_at", "author_id"], name: "analytics_index_audit_events_on_created_at_and_author_id"
t.index ["entity_id", "entity_type"], name: "index_audit_events_on_entity_id_and_entity_type" t.index ["entity_id", "entity_type", "id"], name: "index_audit_events_on_entity_id_and_entity_type_and_id_desc", order: { id: :desc }
end end
create_table "award_emoji", id: :serial, force: :cascade do |t| create_table "award_emoji", id: :serial, force: :cascade do |t|
......
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