Hi,

I have implemented a simple search functionality on my site. I
searches through 8,000 entries and it takes quite long (10-15 seconds)
to respond. Before looking into indexing and other more complex search
options, I'd like to see if I can optimise my code a little bit.
Here's the code:

def search(request):
    ....
                query = Q()
                for term in terms:
                        q = Q(title__icontains = term) \
                  | Q(abstract__icontains = term) \
                  | Q(content__icontains = term) \
                        query = query & q

                search_results = 
Resource.objects.filter(query).order_by('-date')

                news_results = search_results.filter(type='News')[:100]
                event_results = search_results.filter(type='Event')[:100]
....


Then, in the template, I display the event and news results separately
with 2 'for' loops.

Does having 2 querysets make it slower than if I only had one
('search_results'), and looped twice into it in the template to
discriminate the event results from the news results?

Thanks a lot for you help!

Julien
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to