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

Check useless order by on some ORM prefetches #470

Open
roxblnfk opened this issue Mar 18, 2024 Discussed in #469 · 0 comments
Open

Check useless order by on some ORM prefetches #470

roxblnfk opened this issue Mar 18, 2024 Discussed in #469 · 0 comments
Assignees
Labels
status:to be verified Needs to be reproduced and validated.

Comments

@roxblnfk
Copy link
Member

Discussed in https://github.com/orgs/cycle/discussions/469

Originally posted by LLyaudet March 18, 2024
Hello,

Recently I found a problem with Django and submitted a patch in a PR:
https://code.djangoproject.com/ticket/35309
django/django#17984
I also developped a work-around for old versions of Django:
https://github.com/LLyaudet/django-monkey-patches/blob/main/src/django_monkey_patches/django__orm__prefetch_without_useless_order_by.py

I don't know yet Cycle ORM details.
The idea is just that some models can have a default ordering (I assume this functionality is present in Cycle ORM also).
And that some ORM may still add this ordering in the SQL query whilst it is not needed because only a single object will be prefetched per instance of the original result set.
On very big prefetches I noticed a gain of 10 - 15 %,
since the rest of the DB query is mainly an index scan.
#ClimateChangeBrake

Can someone please dump the queries of such prefetches and see if the bug is present in Cycle ORM ?
If so submitting a PR should not be too hard.
I will try to help.
But right now, I start by warning the frameworks/ORM I am aware of :)

Best regards,
Laurent Lyaudet

@roxblnfk roxblnfk added the status:to be verified Needs to be reproduced and validated. label Mar 18, 2024
@roxblnfk roxblnfk added this to Cycle Mar 18, 2024
@roxblnfk roxblnfk moved this to Todo in Cycle Mar 18, 2024
@roxblnfk roxblnfk assigned msmakouz and unassigned msmakouz Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated.
Projects
Status: Todo
Development

No branches or pull requests

2 participants