Repository navigation
IA-5486 bulk upload import cache - #3389
Merged
Merged
Conversation
…k insert audit rows
Phil-V
approved these changes
Oct 6, 2026
Contributor
Author
|
alea iacta est |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem is this PR solving?
Bulk zip upload: cache instances, org units, entities per batch, bulk insert audit rows
Related JIRA tickets
IA-5486
Changes
Fewer SQL queries per submission in
process_mobile_bulk_upload/import_data. No change in behaviour: the tests added in IA-5485 pass unchanged, only their query counts drop.Cached / prefetched per batch (
InstanceImportCache, new)import_data, and for an existing instance 2 more lookups, the task's.get()and the load of its entity.find_entity()takes the cached list (existing_entities=); its rules (create, duplicates, soft-deleted) are unchanged.Lists are kept per uuid: older data can have duplicate uuids, which are handled as before (
.get()still fails the import on duplicate instances).Other
Modification): built withlog_modification(..., save=False), then bulk-inserted in chunks of 500 instead of 1 INSERT per instance.import_datareloads the instance's status, since the in-memory instance is now reused and would otherwise save the rolled-back PENDING.Result (local, SQL queries / time)
4 fewer queries per new submission, about 5 per re-sent one. S3 calls unchanged. On staging, where S3 dominates, expect roughly 5–10%.
Not in this PR
get_or_create+ UPDATE instead of a single INSERT.How to test
Print screen / video
IA-5486 (instance, org unit and entity cache, bulk audit rows) against develop
Measured locally on the same scenarios as before: averages of 3 runs, 2 runs at 2,000.
All new (registration plus follow-up per patient):
Campaign (registrations sent again, updated, plus new follow-ups):
Per submission: 4 fewer queries for a new one (its uuid lookup, the audit INSERT, the org unit, the entity). For a campaign batch it's about 5 fewer on average: each re-sent registration also skips 3 uuid lookups and the load of its entity.
S3 calls don't change: the same number of exists() and saves before and after.
On staging (estimate)
Locally the database answers almost instantly, so these percentages overstate what you'll see on staging. There, most of the ~85ms per submission is S3, which this work doesn't touch. At about 1–2ms per query:
Notes
Doc