On Mon, 9 Sep 2013 06:57:46 -0700 (PDT) Yegor Roganov <yegor....@gmail.com> wrote:
> Thanks for you replies. > But I wonder how real production web sites deal with this problem. The > problem is that I want to display about 30 topics per page which would > result in 30+1 queries if implemented naively. If I write the required > query in raw SQL, it should be faster, but probably not very fast > anyway. Also I don't know how to cache properly since topics should be > ordered by most recent posts (that is, if someone posts to topic on > third page, this topic should become the first one on the first page). > If you were using Postgres or similar, you could create some triggers and/or stored-procedures that maintained an active list of 30 target items - perhaps with a flag in one of the database tables. Then create a view to generate the list of 30 items you needed. This way the ORM & Django SQL access is reduced to a single query on the view. The heavy lifting is all done server-side as comments/articles are saved Could this work? -- Drew Ferguson -- 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.