On Wed, Mar 23, 2011 at 11:51 AM, Christophe Pettus <[email protected]> wrote: > Looking at the SQL, it looks like the way MySQL executes the IN is to read in > and sort all of the Topic records, then probing for the matching ones once > they're sorted.
it only does a linear when the number of IN entries is a significant part of the whole table. > > Generally, if you can avoid IN, especially in MySQL, it's a good idea. not really, typically the number of IN entries is trivial compared to the whole universe of choices. in that case it creates a temporary table with the entries and does a JOIN, with all the optimization opportunities of a typical JOIN. in this case the problem arises because of the big mismatch between the forums_forum table (just 15 records) and the forums_topic table (12k records) that, and the need to sort by a field on another (bigger) table: forums_post.created_date -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

