Ticket #3541: faster_count.patch
File faster_count.patch, 764 bytes (added by , 18 years ago) |
---|
-
django/db/models/query.py
194 194 yield obj 195 195 196 196 def count(self): 197 "Performs a SELECT COUNT() and returns the number of records as an integer." 197 """ 198 Returns the number of records as an integer. 199 200 If _result_cache has been loaded, do len(self._result_cache) 201 otherwise perform a SELECT COUNT(). 202 """ 203 if self._result_cache is not None: 204 return len(self._result_cache) 205 198 206 counter = self._clone() 199 207 counter._order_by = () 200 208 counter._select_related = False