-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
prefetch for engagements all page #4033
prefetch for engagements all page #4033
Conversation
wdyt @danielnaab |
@valentijnscholten sorry to hear about the problems - I tested this locally on a copy of our prod db. I had found that while those prefetches reduce the query count, they nonetheless increase the total time to render the page. But this could definitely be due to something specific about our database. This is what I'm seeing (via django-debug-toolbar): Before prefetches:
With prefetches:
So despite reducing the query count, the total time is ~4.5 times slower. This is with 12 rows in the rendered /engagements_all table, and no tags on any of the engagements. How does your total render time compare? |
To be sure, are you looking at the page at My numbers are:
When disabling the debug toolbar the without scenario becomes a bit faster, but still slower than without prefetching. |
to be honest, that whole page should be rewritten because it does everything based on product instead of engagement. |
Yeah it's odd. We definitely found the queries themselves weren't the main issue with our performance, but something in the ORM layer. We do have a lot of tests, so I suspect the ORM-layer is getting caught up trying to map all the prefetched objects' over all the various relations. For an idea, this shows our test count per engagement: |
Yes, with those amounts of tests it will go crazy. For we should prefetch the count by using |
OK, couldn't help myself and updated the PR. It now counts the tests using an SQL query instead of loading all tests into memory. Could you try this maybe? |
@valentijnscholten that works great - here's updated numbers: Before prefetches:
With prefetches
With prefetches + prefetch count:
|
Not bad with that CRAZY amount of tests 😜 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
After updating to the latest dev I noticed the
engagements_all
page was slow, executing 300+ queries.This PR adds some needed prefetching. Not sure if this removed at some point, but seems to work fine now.