summaryrefslogtreecommitdiff
path: root/docs/topics/db/optimization.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/topics/db/optimization.txt')
-rw-r--r--docs/topics/db/optimization.txt22
1 files changed, 11 insertions, 11 deletions
diff --git a/docs/topics/db/optimization.txt b/docs/topics/db/optimization.txt
index dda7e9504a..baea968fdb 100644
--- a/docs/topics/db/optimization.txt
+++ b/docs/topics/db/optimization.txt
@@ -224,21 +224,21 @@ many-to-many relation to User, the following template code is optimal:
It is optimal because:
- 1. Since QuerySets are lazy, this does no database queries if 'display_inbox'
- is False.
+1. Since QuerySets are lazy, this does no database queries if 'display_inbox'
+ is False.
- #. Use of :ttag:`with` means that we store ``user.emails.all`` in a variable
- for later use, allowing its cache to be re-used.
+#. Use of :ttag:`with` means that we store ``user.emails.all`` in a variable
+ for later use, allowing its cache to be re-used.
- #. The line ``{% if emails %}`` causes ``QuerySet.__nonzero__()`` to be called,
- which causes the ``user.emails.all()`` query to be run on the database, and
- at the least the first line to be turned into an ORM object. If there aren't
- any results, it will return False, otherwise True.
+#. The line ``{% if emails %}`` causes ``QuerySet.__nonzero__()`` to be called,
+ which causes the ``user.emails.all()`` query to be run on the database, and
+ at the least the first line to be turned into an ORM object. If there aren't
+ any results, it will return False, otherwise True.
- #. The use of ``{{ emails|length }}`` calls ``QuerySet.__len__()``, filling
- out the rest of the cache without doing another query.
+#. The use of ``{{ emails|length }}`` calls ``QuerySet.__len__()``, filling
+ out the rest of the cache without doing another query.
- #. The :ttag:`for` loop iterates over the already filled cache.
+#. The :ttag:`for` loop iterates over the already filled cache.
In total, this code does either one or zero database queries. The only
deliberate optimization performed is the use of the :ttag:`with` tag. Using