Skip to content
Snippets Groups Projects
Commit d62aaa9f authored by Jan Provaznik's avatar Jan Provaznik
Browse files

Add confidential notes index

Adds an index on confidential notes using ID field and removes
old index which used confidential field (which was not ideal for
iterating through confidential notes in batches).

Changelog: added
parent 904ecdbf
No related branches found
No related tags found
1 merge request!90007Add confidential notes index
# frozen_string_literal: true
class CreateConfidentialNotesIndexOnId < Gitlab::Database::Migration[2.0]
OLD_INDEX_NAME = 'index_notes_on_confidential'
INDEX_NAME = 'index_notes_on_id_where_confidential'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :notes, name: OLD_INDEX_NAME
add_concurrent_index :notes, :id, where: 'confidential = true', name: INDEX_NAME
end
def down
# we don't have to re-create OLD_INDEX_NAME index
# because it wasn't used yet, also its creation might be expensive
remove_concurrent_index_by_name :notes, name: INDEX_NAME
end
end
1d2dc45d6fae911d75eaf5970afbae6d2f31d2efd1c27b75fce5feacbcc319d3
\ No newline at end of file
......@@ -28614,12 +28614,12 @@ CREATE INDEX index_notes_on_author_id_and_created_at_and_id ON notes USING btree
 
CREATE INDEX index_notes_on_commit_id ON notes USING btree (commit_id);
 
CREATE INDEX index_notes_on_confidential ON notes USING btree (confidential) WHERE (confidential = true);
CREATE INDEX index_notes_on_created_at ON notes USING btree (created_at);
 
CREATE INDEX index_notes_on_discussion_id ON notes USING btree (discussion_id);
 
CREATE INDEX index_notes_on_id_where_confidential ON notes USING btree (id) WHERE (confidential = true);
CREATE INDEX index_notes_on_line_code ON notes USING btree (line_code);
 
CREATE INDEX index_notes_on_noteable_id_and_noteable_type_and_system ON notes USING btree (noteable_id, noteable_type, system);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment