瀏覽代碼

Fixed #33046 -- Added note about using length of cached result by QuerySet.count().

Can Sarıgöl 3 年之前
父節點
當前提交
7ea86076fc
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      docs/ref/models/querysets.txt

+ 3 - 0
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()``
 ~~~~~~~~~~~~~