Commit f92fcf60 authored by Felipe Artur's avatar Felipe Artur

Index issues on sent_notifications

Add index to sent_notifications table to prevent statement timeouts
parent 77885f3a
---
title: Index issues on sent_notifications table
merge_request: 27034
author:
type: performance
# frozen_string_literal: true
class AddIndexOnNoteableTypeAndNoteableIdToSentNotifications < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_sent_notifications_on_noteable_type_noteable_id'
disable_ddl_transaction!
def up
add_concurrent_index :sent_notifications,
[:noteable_id],
name: INDEX_NAME,
where: "noteable_type = 'Issue'"
end
def down
remove_concurrent_index_by_name :sent_notifications, INDEX_NAME
end
end
......@@ -3919,6 +3919,7 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
t.string "note_type"
t.text "position"
t.string "in_reply_to_discussion_id"
t.index ["noteable_id"], name: "index_sent_notifications_on_noteable_type_noteable_id", where: "((noteable_type)::text = 'Issue'::text)"
t.index ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true
end
......
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