Problem is that you have to be able to express it in SQL. And thus ther is not 
much you can do in SQL to get what you actually wanted.

Considering amount of the data fetched - it's relatively low query count and 
unless you're hitting very busy site you wont notice much of difference doing 
this in 6 queries.

One to fetch last 5 topics and then 5 to get that 20 latest posts per topic.

When you later may hit really busy site you can cache list for a short time to 
relieve load on db.

On Sun, 8 Sep 2013 14:13:09 -0700 (PDT)
Yegor Roganov <yegor....@gmail.com> wrote:

> I found out this is a so called "top n per group" problem and it's not that 
> easy to implement in django. Maybe someone could help me to find another 
> way (for example, alter the schema in some way)?
> 
> -- 
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to