Skip to content
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

fix(db-mongodb): incorrect join aggregation order causes perf issues, remove mongoose-aggregate-paginate-v2 #10936

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Feb 2, 2025

Fixes #10165 (reply in thread)

As described in the discussion, we have an incorrect order of aggregation pipeline when using aggregations with the join field. We must use $sort, $skip, $limit before the $lookup or otherwise mongodb scans all the docs, applies $lookup for them and only after applies $limit, $skip.
Replaces mongoose-aggregate-paginate-v2 with a custom aggregatePaginate because we need a custom solution here. This was considered in #9594 but it was reverted as for now.

@r1tsuu r1tsuu marked this pull request as ready for review February 2, 2025 20:40
@r1tsuu r1tsuu force-pushed the fix/incorrect-order-of-aggreagation branch from f37d314 to 2f75573 Compare February 2, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant