On Tue, Mar 29, 2011 at 5:56 AM, Malcolm Box <malcolm....@gmail.com> wrote:
> On one of my models, the admin choice_list page is taking minutes to
> load, which makes it somewhat broken.
>
> The table has about 2M rows and about 2.6GB in size, on InnoDB/MySQL.
> As far as I can tell, what's breaking things is the paginator code
> that is doing a SELECT COUNT(*) which is known to be glacially slow on
> InnoDB with certain types of table.

Yup, this is a known problem: pagination in the admin isn't efficient
and breaks down past a certain point.

> Is there any way to suppress the pagination and/or change it so that
> it doesn't do the queryset.count()?

In 1.3 you should be able to override ModelAdmin.get_paginator
(http://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_paginator).
You'll have to subclass django.core.paginator.Paginator and provide an
interface that doesn't perform COUNTs.

[Yes, this is sorta tricky, and ideally it'd be something Django does
for you so if you'll share your code when you figure it out I'll try
to work it into the next release.]

Jacob

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to