Skip to content

Commit

Permalink
Added warning about the performance of large IN clauses in prefetch_r…
Browse files Browse the repository at this point in the history
…elated docs

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17147 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed Nov 24, 2011
1 parent 648adcd commit e954a03
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/ref/models/querysets.txt
Expand Up @@ -821,6 +821,12 @@ referenced is needed, rather than one query for all the items. There could be
additional queries on the ``ContentType`` table if the relevant rows have not
already been fetched.

``prefetch_related`` in most cases will be implemented using a SQL query that
uses the 'IN' operator. This means that for a large QuerySet a large 'IN' clause
could be generated, which, depending on the database, might have performance
problems of its own when it comes to parsing or executing the SQL query. Always
profile for your use case!

extra
~~~~~

Expand Down

0 comments on commit e954a03

Please sign in to comment.