mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #20877 -- added a performance optimization guide
This commit is contained in:
parent
4db2752e28
commit
dc8f95b639
6 changed files with 403 additions and 22 deletions
|
@ -88,7 +88,8 @@ of parentheses, but will call callables automatically, hiding the above
|
|||
distinction.
|
||||
|
||||
Be careful with your own custom properties - it is up to you to implement
|
||||
caching.
|
||||
caching when required, for example using the
|
||||
:class:`~django.utils.functional.cached_property` decorator.
|
||||
|
||||
Use the ``with`` template tag
|
||||
-----------------------------
|
||||
|
@ -111,10 +112,11 @@ For instance:
|
|||
* At the most basic level, use :ref:`filter and exclude <queryset-api>` to do
|
||||
filtering in the database.
|
||||
|
||||
* Use :class:`F expressions <django.db.models.F>` to do filtering
|
||||
against other fields within the same model.
|
||||
* Use :class:`F expressions <django.db.models.F>` to filter
|
||||
based on other fields within the same model.
|
||||
|
||||
* Use :doc:`annotate to do aggregation in the database </topics/db/aggregation>`.
|
||||
* Use :doc:`annotate to do aggregation in the database
|
||||
</topics/db/aggregation>`.
|
||||
|
||||
If these aren't enough to generate the SQL you need:
|
||||
|
||||
|
@ -233,6 +235,8 @@ queryset``.
|
|||
|
||||
But:
|
||||
|
||||
.. _overuse_of_count_and_exists:
|
||||
|
||||
Don't overuse ``count()`` and ``exists()``
|
||||
------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue