mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #16937 - added QuerySet.prefetch_related
to prefetch many related objects.
Many thanks to akaariai for lots of review and feedback, bug finding, additional unit tests and performance testing. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16930 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d30fbf8b78
commit
662eea116f
10 changed files with 968 additions and 24 deletions
|
@ -141,10 +141,12 @@ retrieving it all in one query. This is particularly important if you have a
|
|||
query that is executed in a loop, and could therefore end up doing many database
|
||||
queries, when only one was needed. So:
|
||||
|
||||
Use ``QuerySet.select_related()``
|
||||
---------------------------------
|
||||
Use ``QuerySet.select_related()`` and ``prefetch_related()``
|
||||
------------------------------------------------------------
|
||||
|
||||
Understand :ref:`QuerySet.select_related() <select-related>` thoroughly, and use it:
|
||||
Understand :meth:`~django.db.models.query.QuerySet.select_related` and
|
||||
:meth:`~django.db.models.query.QuerySet.prefetch_related` thoroughly, and use
|
||||
them:
|
||||
|
||||
* in view code,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue