Commit 2a6c75fa authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Remove trigram index on notes

This removes the GIN index on notes because these are expensive to
update. This causes note creation to sometimes time out.

This query is also seldom used. We only search for notes in the Global
Search page and only searches within projects are allowed. And when
searching within a project, this global index is unlikey to be used and
might even degrade performance as we see in issue searches. For issue
searches within a project, we use a CTE to avoid the global trigram
index.

Changelog: performance
parent b773abc0
# frozen_string_literal: true
class RemoveNotesTrigramIndex < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
NOTES_TRIGRAM_INDEX_NAME = 'index_notes_on_note_trigram'
def up
remove_concurrent_index_by_name(:notes, NOTES_TRIGRAM_INDEX_NAME)
end
def down
add_concurrent_index :notes, :note, name: NOTES_TRIGRAM_INDEX_NAME, using: :gin, opclass: { content: :gin_trgm_ops }
end
end
166ae24ae4856488c81a71c650dca038c8cd7cb2221545e84431e118da097688
\ No newline at end of file
......@@ -26539,8 +26539,6 @@ CREATE INDEX index_notes_on_discussion_id ON notes USING btree (discussion_id);
CREATE INDEX index_notes_on_line_code ON notes USING btree (line_code);
CREATE INDEX index_notes_on_note_trigram ON notes USING gin (note gin_trgm_ops);
CREATE INDEX index_notes_on_noteable_id_and_noteable_type_and_system ON notes USING btree (noteable_id, noteable_type, system);
CREATE INDEX index_notes_on_project_id_and_id_and_system_false ON notes USING btree (project_id, id) WHERE (NOT system);
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