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?
--
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.