Hi,

I have an application that needs to do a fairly big search across a large 
number of records that goes something like...

filterList = accounts.objects.filter(name="foo", company="bar", blah blah 
blah..)

itemsList = items.objects.filter(account__in=accountList, 
status="delivered", andSo="on"....)



The problem that I would like to overcome is that the 
'account__in=accountList' creates some very inefficient SQL and slow's this 
query down a lot.

What I thought of doing instead was:

filterList = accounts.objects.filter(name="foo", company="bar", blah blah 
blah..)

for account in filterList:

    itemsList = items.objects.filter(account=account, status="delivered", 
andSo="on"....)

    # I know it's not possible to extend a django queryset, I'm looking for 
an equivalent
    wholeItemsList.extend(itemsList)


Now I know the .extend method won't work on a django queryset, and I 
realise that it's possible to convert the queryset to a list and than 
extend them but that would use a horrible ammount of memory to duplicate 
the queryset in this instance and wouldn't give me much of a time advantage.

What I would like to do is to add each of the querysets, searching for them 
without the '__in' filter saves a lot on sql, but then I don't want to 
loose the efficiency that would gain by adding another latency.

Any Ideas would be greatly appreciated....


Many thanks,

Neil


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/32O_GEs1cUUJ.
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