O3-5763: Fetch queue entry associations lazily - #122
Merged
ibacher merged 2 commits intoAug 25, 2026
Conversation
QueueEntry and Queue left their *ToOne associations at the JPA default of EAGER, so reading one queue entry pulled every association's own eager graph in a single 30-join statement. On a fresh database, which ships zero-row statistics, that statement does not finish; lazily it returns in about a second. Also excluded from Lombok's equals, hashCode and toString, which would otherwise re-initialise the proxies.
ibacher
reviewed
Aug 25, 2026
Address review feedback: BaseOpenmrsObject already implements both in terms of the UUID, so the entities don't need Lombok's generated versions. That also removes the need to exclude each association from them.
|
Member
Yeah, that's also meant to be being fixed... |
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.



Summary
service-queues.spec.tsin #2600 started timing out once the suite created a queue entry.QueueEntryleaves all eight*ToOneassociations at the JPA default ofEAGER, andQueuedoes the same for its four@ManyToOnefields. Reading one entry pulls every association's own eager graph in a single statement — 21KB of SQL, 30 joins. On a fresh install, which ships zero-row table statistics, the optimizer plans that badly.Same database, same 51 entries, the query the frontend actually makes:
main)Worth Noting:
v=ref,v=default,v=fullandisEnded=false. Serialisation happens inside the request session, so noLazyInitializationException.Patient,VisitandConceptbring their own eager graphs from core.Related Issue
O3-5763