-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repository v3.7.3: inefficient inclusion lookup when ANY scope props defined #8074
Comments
Thanks for the detail explanation @allanpaiste. You are right, if the scope has only a If that's right I can push a PR later this week to limit this to only |
@collaorodrigo7 If memory serves, I don't think there's an equivalent to "skip" in SQL left joins. So the check should only apply to LIMIT relation filters. |
Any updates on this @collaorodrigo7 ? :) |
@collaorodrigo7 I'd take it's a one-liner fix where we just add a conditional around that logic-branching? Yes? |
The fix should be a one-liner fix, though I've not checked on it yet. I'll try to timebox this week to fix the issue, but if you can open a PR earlier, I can help review it with the other mantainers. |
fixes: #8074 Signed-off-by: Rifa Achrinza <[email protected]>
fixes: #8074 Signed-off-by: Rifa Achrinza <[email protected]>
Sorry guys, I had to take a short time off and couldn't take a look at this before leaving. |
fixes: #8074 Signed-off-by: Rifa Achrinza <[email protected]>
Previously inclusion lookup was done with a single query that used inq filter that involves every fkValue where now (since 3.7.3) the lookup is performed with find per fkValue.
The new implementation itself states (in code comment) that it is used for very specific cases, but there are no checks implemented in code to validate that such case (as stated in the comment that you can see in the code) was actually encountered.
loopback-next/packages/repository/src/relations/relation.helpers.ts
Lines 65 to 75 in 5d1a8c7
This issue report stems from a discovery where certain inclusion lookup that previously produced 1 query now produces 494 instead - which DID result in very noticeable performance impact.
Steps to reproduce
Current Behavior
Loopback ends up doing 5 separate FIND queries for the relations.
Expected Behavior
Loopback does a single FIND query for the relations with inq: [1, 2, 3, 4, 5]
Additional information
The steps/example given uses small number of entities, but you can probably see how this issue escalates when you are dealing with thousands of records.
I don't see any reason why the implementation that caused this issue should be used for anything than in situation where developer defines a 'limit' for specific scope, and even then I would question if this should be something that gets implemented without a huge warning label attached to it as it introduces serious performance degradation.
The fact that this was introduced in a PATCH semver is also troubling as it diminishes the trust where one expects fix releases to introduce fixes rather than introducing code logic branches with completely new execution strategy
Proposed fix
Recommendation for others who encounter this
Lock your @loopback/repository to 3.7.2 until this issue gets fixed.
Related Issues
#6832 (introduced the issue)
The text was updated successfully, but these errors were encountered: