-
- Downloads
Optimize DB indexes for ES indexing of notes
To index notes, we exclude system notes and use `find_in_batches` to load them in batches for submission to the ES bulk import API. These queries often result in DB timeouts because the usage of `ORDER BY id` results in the `notes_pkey` index being used. This adds an optimized partial index, and removes the unused index `index_notes_on_noteable_type` which is already covered for our usage by the existing `index_notes_on_noteable_id_and_noteable_type`. Newer versions of PostgreSQL (at least 11) are smarter about this and use `index_notes_on_project_id_and_noteable_type` instead, so we might be able to remove the partial index again in the future.
Showing
- changelogs/unreleased/optimize-note-indexes.yml 5 additions, 0 deletionschangelogs/unreleased/optimize-note-indexes.yml
- db/migrate/20190815093936_add_index_notes_on_project_id_and_id_and_system_false.rb 30 additions, 0 deletions..._add_index_notes_on_project_id_and_id_and_system_false.rb
- db/migrate/20190815093949_remove_index_notes_on_noteable_type.rb 29 additions, 0 deletions...ate/20190815093949_remove_index_notes_on_noteable_type.rb
- db/schema.rb 2 additions, 2 deletionsdb/schema.rb
Please register or sign in to comment