summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2009-12-22 17:32:30 +0000
committerLuke Plant <L.Plant.98@cantab.net>2009-12-22 17:32:30 +0000
commita5af81f93fdf79a99d59a7cabd14ce58266d1d10 (patch)
treed17653fb26fba2ea573954756cc5928ab4375b92 /docs/ref
parent51602128a57e8cf93f3cdb1f1370deba93f034ec (diff)
Improved documentation of when QuerySet.exists() and .count() are a genuine optimization.
Also fixed a typo. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11960 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/querysets.txt10
1 files changed, 7 insertions, 3 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 45f1c3161b..fe94aa006f 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1037,7 +1037,8 @@ Example::
``count()`` performs a ``SELECT COUNT(*)`` behind the scenes, so you should
always use ``count()`` rather than loading all of the record into Python
-objects and calling ``len()`` on the result.
+objects and calling ``len()`` on the result (unless you need to load the
+objects into memory anyway, in which case ``len()`` will be faster).
Depending on which database you're using (e.g. PostgreSQL vs. MySQL),
``count()`` may return a long integer instead of a normal Python integer. This
@@ -1140,8 +1141,11 @@ Aggregation <topics-db-aggregation>`.
Returns ``True`` if the :class:`QuerySet` contains any results, and ``False``
if not. This tries to perform the query in the simplest and fastest way
possible, but it *does* execute nearly the same query. This means that calling
-:meth:`QuerySet.exists()` is faster that ``bool(some_query_set)``, but not by
-a large degree.
+:meth:`QuerySet.exists()` is faster than ``bool(some_query_set)``, but not by
+a large degree. If ``some_query_set`` has not yet been evaluated, but you know
+that it will be at some point, then using ``some_query_set.exists()`` will do
+more overall work (an additional query) than simply using
+``bool(some_query_set)``.
Field lookups
-------------