On Mar 23, 2011, at 8:45 AM, Brian Neal wrote: > Sorry, my bad. I've been tweaking things in vain. Here are the correct > EXPLAINS. > > http://dpaste.com/524865/
In both cases, what it's doing is grabbing a set of records from Topic, sorting them, then using those to select Posts. In the second one, it is grabbing *all* of the topics to sort, and my guess is that it is spilling to disk in doing the sort, which is why it takes so long (although 7 seconds to sort 12k records is pretty bad... have you considered using PostgreSQL instead? :) ). 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. Generally, if you can avoid IN, especially in MySQL, it's a good idea. -- -- Christophe Pettus x...@thebuild.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.