[p2pu-dev] A little SQL/Django ORM riddle to start off the week!
dirk at p2pu.org
Mon Jan 7 07:55:02 UTC 2013
I've been investigating some of the SQL queries that's really slow. I've
noticed that we are using quite a few queries that uses sub-queries -
"where value1 in (select value 2 from ... )
So, as a first example (and also one of the slowest queries):
We have this function:
that generate this SQL: https://gist.github.com/4473163
I've rewritten the query using only joins to achieve the same (faster):
So the riddle: how do you get Django's ORM to generate something more like
the second query?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the p2pu-dev