On Wed, Mar 23, 2011 at 10:45 AM, Brian Neal <bgn...@gmail.com> wrote:
> Sorry, my bad. I've been tweaking things in vain. Here are the correct
> EXPLAINS.
>
> http://dpaste.com/524865/

ok, now it's obvious.

the second query (the one with topic__forum__in=forums, right?) is
scanning the whole topic table (12Krows).  it seems to be guessing
that picking a significant fraction of a very small space (5 forums
out of 15, right?) wouldn't be so much better using the index.

the first query is using the topic->forum key, narrowing the loop to
the ~1388 topics of the given forum.

now, how to improve this?  it seems a little denormalization is in
order.  i can thing of two different options:

A: add a 'last_post_date' field to the topics table, and select only
the most recent 10 or so topics.

B: add a new post->forum relation, and maybe a (forum,post_date) index

-- 
Javier

-- 
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.

Reply via email to