> Is there a way to identify which queries use cloning?

Every filter, exclude, order_by, select_related and some other calls
clones it. Slicing too.

> Is there a way rewrite those queries to avoid cloning overhead?

You can rewrite
qs.filter(a=1).exclude(b=2) as qs.filter(Q(a=1) & !Q(b=2))
or
qs = qs.filter(a=1); ...; qs = qs.filter(b=2) as q = {}; q['a'] =
1; ...; q['b'] = 2; qs = qs.filter(**q)

But you can't avoid several cloning procs for queryset not modifying
django or monkey patching.

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