[Hotfix] Add BaseFileNode index for target/provider/type #8850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Avoid costly BitmapHeap Scan when doing things like
OsfStorageFolder.objects.filter(target=node)
, etc.Changes
index_together
QA Notes
See if files load any faster? No direct UI changes, may not affect the generic file page queries (especially not until the table is vacuumed, which happens automatically over long periods of time). Added specifically to further optimize #8849
Side Effects
None expected, other than what's listed below
Deployment Notes
Because this is decently-sized index on one of our largest tables, this MUST NOT be deployed without downtime. Indices require exclusive table locks while being created*, therefore this requires maintenance downtime.
* Except concurrently, which is technically possible but not supported by Django. Doing so would require the migration operation to be something like:
However, due to caveats, it's possible that index would not be successfully created, leading to increased overhead and none of the benefits, and possible deadlock during the failed creation process.
Ticket
None known