On Sunday 11 June 2017 09:15:09 Miika Huusko wrote:
> Thanks for response!
> 
> Yep, timing with "time" is not the best way to go to compare SQL query
> times. The reason I added that "time" test is that in Stack Overflow
> I was asked to confirm that data transfer is not factor here. I timed
> SQL queries with "EXPLAIN ANALYZE" and "\timing" first. That don't
> take data transfer into account, so, "time" as quick test that data
> transfer is not a problem.
> 
> About timing: as an example I can reduce the problem to serializing
> only Items and related Photos. It results only two queries. For
> example for a dataset of about 40k items results:
> 
> django.db.backends: (1.252) SELECT "todo_item"."version", *... all
> item properties ...* FROM "todo_item" WHERE ("todo_item"."project_id"
> = '...' AND "todo_item"."deleted_at" IS NULL);
> 
> django.db.backends: (0.883) SELECT "photos_photo"."version", *... all
> item properties ...* FROM "photos_photo" WHERE
> "photos_photo"."note_id" IN (349527, 349528, 349529, *... and rest of
> the 40k IDs ...* );

Why did you opt to use prefetch_related and not select_related?

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/24568739.Jy3x7NNMDG%40devstation.
For more options, visit https://groups.google.com/d/optout.

Reply via email to