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) posts = thepage.object_list is_paginated = True base_url = "/news/browse" return render_to_response('news/browse.html', locals(), context_instance=RequestContext(request)) The query this runs looks like this: SELECT "feedjack_post"."id","feedjack_post"."feed_id","feedjack_post"."title","feedjack_post"."link","feedjack_post"."content","feedjack_post"."date_modified","feedjack_post"."guid","feedjack_post"."author","feedjack_post"."author_email","feedjack_post"."comments","feedjack_post"."date_created" FROM "feedjack_post" WHERE ("feedjack_post"."feed_id" IN (11,13,14,15)) ORDER BY "feedjack_post"."date_modified" DESC whats happening is that pulling out a ton of rows from the database and creating model objects from each row. Since the row has almost 250K rows, and reach row retrieved pulls back an off row storage column "content" which can be 5-25KB in size, this current system is taking an absurd amount of time when it doesnt need to be. This doesnt seem to make a ton of sense since i really only need the count of the total matching rows, and the model objects for the first 10. I assumed that since the query set is lazy and I'm not trying to retreive the values of the queryset before i pass it to the paginator, it would build up the paginator in an efficient way. Am i doing somethign wrong here or is this how the paginator normally works? Any suggestions? note: my db is correctly indexed, the problem is that more than the required rows are being returned from the DB. Running .count() [ select count(*) ] only takes a few milliseconds. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---