Evan wrote: > Hey Guys I noticed one of my pages taking over 50seconds to load, and > found the problem out the problem was the paginator loading a lot more > rows than needed. I was wondering if this is how the paginator is > supposed to work or if I'm doing something incorrect. > > Here's the view i'm using > def browse_posts(request, cur_page=1): > feeds = [11,13,14,15] > posts = Post.objects.filter(feed__in=feeds).order_by('- > date_modified') > cur_page=int(cur_page) > results_per_page = 10 > paginator = Paginator(posts, results_per_page) > thepage = paginator.page(cur_page)
This gets you what you want...it efficiently uses LIMIT where it can (I presume you're using one of the big-3 DBs, MySQL, PostgreSQL, or sqlite, rather than an old/hacked version that allows SQL Server, which doesn't support a LIMIT/OFFSET syntax, but only a TOP N syntax) > posts = thepage.object_list this is what likely gives you the problems, as it's the whole record-set. > is_paginated = True > base_url = "/news/browse" > return render_to_response('news/browse.html', locals(), > context_instance=RequestContext(request)) which you're passing via locals() So if your template makes use of "posts" anywhere (including debugging output), instead of using "thepage", you'll see the dire times you're seeing. -tim --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---