Changes between Version 1 and Version 2 of Ticket #25787, comment 3
- Timestamp:
- Nov 21, 2015, 9:08:57 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25787, comment 3
v1 v2 1 1 If that executes lazily then I am ok with this, thank you. 2 2 3 However looking at the code for QuerySet it defines an {{{__iter__}}} method but no {{{__contains__}}} method and {{{__iter__}}} executes {{{_fetch_all}}}, which means instead of doing an {{{.exists()}}} query using {{{in}}} on a query set fetches a large number of objects and iterates over the result. This is very inefficient. 3 However looking at the code for QuerySet it defines an {{{__iter__}}} method but no {{{__contains__}}} method and {{{__iter__}}} executes {{{_fetch_all}}}, which means instead of doing an {{{.exists()}}} query using {{{in}}} on a query set fetches a large number of objects and iterates over the result objects rather than using the database aided {{{.exists()}}}. 4 This is very inefficient.