Timeline for Speed up performance of nested for loops to get all related format of all Authors' Books
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 20, 2017 at 13:34 | comment | added | thumbtackthief |
I'm afraid I can't post the real models for proprietary reasons, but Author has a lot of fields, so does Book, which FKs to Author, and so does Book_Format, which FKs to Author. The original query is actually not .objects.all , it's a filter. Not sure if that makes a difference with prefetch; updating the question.
|
|
Jun 20, 2017 at 13:24 | comment | added | alecxe | @thumbtackthief may be I'm not suggesting the correct use - apologies if this is the case, it's being a while I've used "advanced" Django ORM. It would be really useful to actually see what queries are executed for both with "prefetch_related" and without..and take it from there. Could you please post your current models? I'll see if I can reproduce the problem as well. Thanks. | |
Jun 20, 2017 at 13:20 | comment | added | thumbtackthief |
Unfortunately django-debug-toolbar is not possible with our current set up. I've tried the prefetch and select_related and it hasn't improved performance. values_list improves performance? I haven't encountered that yet.
|
|
Jun 20, 2017 at 2:53 | history | edited | alecxe | CC BY-SA 3.0 |
added 181 characters in body
|
Jun 20, 2017 at 2:48 | history | answered | alecxe | CC BY-SA 3.0 |