Haystack search painfully slow with paginated ListView

151 views
Skip to first unread message

Cerin

unread,
May 21, 2013, 9:13:27 AM5/21/13
to django-...@googlegroups.com

How do you speed up a Haystack-search powered (using the Whoosh backend) paginated Django list view?

I had a simple ListView like:

class PersonListView(ListView)
    template_name = 'person-list.html'
    paginated_by = 10
    def get_queryset(self):
        return Person.objects.all()


Returning a page with 3000 results runs in about 1 second on my localhost.

I then "plugged in" Haystack to allow full-text searching on names by doing:

class PersonListView(ListView)
    template_name = 'person-list.html'
    paginated_by = 10
    def get_queryset(self):
        #return Person.objects.all()
        return SearchQuerySet().models(models.Person)


And I setup the appropriate index and run manage.py rebuild_index:

class PersonIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    nickname = indexes.CharField()
    first_name = indexes.CharField()
    middle_name = indexes.CharField()
    last_name = indexes.CharField()

    def get_model(self):
        return models.Person

    def index_queryset(self, using=None):
        return self.get_model().objects.all()


However, after this, the same page now takes about 15 seconds to run...

I tried using a django profiler, but I don't see much difference in the query times before and after the change, and the longest running query takes only a second, indicating there's some bug on the view side that's causing all the query results to be iterated over.

Am I doing something wrong? What's causing my setup to run so slowly?

Michael Dizon

unread,
Feb 13, 2014, 10:15:15 PM2/13/14
to django-...@googlegroups.com
Did you wind up resolving this issue?

Chris Spencer

unread,
Feb 13, 2014, 11:35:40 PM2/13/14
to django-...@googlegroups.com
Yes. I stopped using Haystack. Now I'm using full text search in PostgreSQL and I can search using native Django models and I can avoid all the nonsense Haystack makes you go through.


--
You received this message because you are subscribed to a topic in the Google Groups "django-haystack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-haystack/OBxyJGd7Zgw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-haysta...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages