From 7ea86076fc1128d43b47f4826cb25eb5ebb19f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20Sar=C4=B1g=C3=B6l?= Date: Wed, 25 Aug 2021 13:44:08 +0200 Subject: [PATCH] Fixed #33046 -- Added note about using length of cached result by QuerySet.count(). --- docs/ref/models/querysets.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 333c0054c6..583d313b5b 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2291,6 +2291,9 @@ retrieving model instances from it (for example, by iterating over it), it's probably more efficient to use ``len(queryset)`` which won't cause an extra database query like ``count()`` would. +If the queryset has already been fully retrieved, ``count()`` will use that +length rather than perform an extra database query. + ``in_bulk()`` ~~~~~~~~~~~~~