Skip to content

Add FAQ about slow joins #320

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

Merged
merged 1 commit into from
Jun 25, 2025
Merged

Conversation

timgraham
Copy link
Collaborator

Some discussion in #309.

Querying across relational fields like :class:`~django.db.models.ForeignKey` and :class:`~django.db.models.ManyToManyField` is really slow. Is there a way to improve the speed of these joins?
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Not really. Joins use MongoDB's :doc:`$lookup
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: "Not really."

We could mention the possibility of using raw_aggregate() to manually construct a query as mentioned in #309, but I think that's unlikely to be an attractive and maintainable solution for most projects.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 we could, the people then will ask: why aren't you doing that approach?
The answer is: because we have to modify the django query tree or handle this particular case differently. IMO keep this as it is now, otherwise we should explain the limitations that we have in this particular case.

@timgraham timgraham requested a review from WaVEV June 25, 2025 14:46
@timgraham timgraham merged commit 84c8299 into mongodb:main Jun 25, 2025
8 of 9 checks passed
@timgraham timgraham deleted the faq-slow-joins branch June 25, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants