optimize deletion of notes attached to subrecords #2292
Merged
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.
Use the same Sequel optimization when removing subnote metadata from nested sub-records that have notes as is used for top-level records.
The resulting change in the SQL statements is as follows:
Before:
DELETE FROM subnote_metadata WHERE (note_id IN (SELECT id FROM note WHERE (rights_statement_id IN (27))))
After:
DELETE subnote_metadata FROM subnote_metadata INNER JOIN note ON (note.id = subnote_metadata.note_id) WHERE (rights_statement_id IN (27))
Related JIRA Ticket or GitHub Issue
#2275
How Has This Been Tested?
Wrote test coverage for updating records with sub records with notes.
Screenshots (if appropriate):
Types of changes
Checklist: