Skip to content

Add indexes to improve join table performance#6645

Open
jhenderson wants to merge 1 commit intonextfrom
add-reverse-indexes-to-import-join-tables
Open

Add indexes to improve join table performance#6645
jhenderson wants to merge 1 commit intonextfrom
add-reverse-indexes-to-import-join-tables

Conversation

@jhenderson
Copy link
Copy Markdown
Contributor

Poor performance has been noted when deleting records in Mavis, particularly in:

  • the bulk-remove parents flow
  • bulk deletion of vaccination records linked to immunisation imports

A likely cause is that some join tables are only indexed in one direction. That means queries which delete or clean up rows via the associated record side of the join can be slower than necessary.

This change adds reverse indexes for the join tables involved in those deletion paths.

These are the delete paths in the job:


The reverse index on immunisation_imports_vaccination_records should improve performance when deleting vaccination records linked to immunisation imports, by making it faster to locate and remove the related join-table rows. This is relevant to the bulk cleanup work discussed in MAV-2997.

Jira Issue - MAV-6735

Poor performance has been noted when deleting records, particularly
in the bulk-remove parents flow and when bulk-deleting vaccination
records.

A likely cause is that some join tables are only indexed in one
direction, which can make deletion queries slower.

Jira-Issue: MAV-6735
@jhenderson jhenderson requested a review from a team as a code owner April 20, 2026 14:31
@jhenderson jhenderson added the performance Improving performance label Apr 20, 2026
@jhenderson jhenderson added this to the v8.2.0 milestone Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Improving performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants