# HG changeset patch # User Brian Neal # Date 1298353229 0 # Node ID 3f9b9fd54b019a8891c59207ef2711cf2183888d # Parent a1bf6cf4972002c526597c2fef7cd9eb2e4fa4a3 Some optimizations to reduce database query times. diff -r a1bf6cf49720 -r 3f9b9fd54b01 gpp/forums/views/main.py --- a/gpp/forums/views/main.py Tue Feb 22 02:11:26 2011 +0000 +++ b/gpp/forums/views/main.py Tue Feb 22 05:40:29 2011 +0000 @@ -127,8 +127,6 @@ } topics = forum.topics.select_related('user', 'last_post', 'last_post__user') - get_topic_unread_status(forum, topics, request.user) - paginator = create_topic_paginator(topics) page_num = get_page_num(request) try: @@ -136,6 +134,7 @@ except InvalidPage: raise Http404 + get_topic_unread_status(forum, page.object_list, request.user) attach_topic_page_ranges(page.object_list) # we do this for the template since it is rendered twice @@ -166,7 +165,7 @@ topic.view_count = F('view_count') + 1 topic.save(force_update=True) - posts = topic.posts.select_related() + posts = topic.posts.select_related(depth=1) paginator = create_post_paginator(posts) page_num = get_page_num(request)