mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Refs #16614 -- Made QuerySet.iterator() use server-side cursors on PostgreSQL.
Thanks to Josh Smeaton for the idea of implementing server-side cursors in PostgreSQL from the iterator method, and Anssi Kääriäinen and Kevin Turner for their previous work. Also Simon Charette and Tim Graham for review.
This commit is contained in:
parent
53bffe8d03
commit
f3b7c05936
13 changed files with 165 additions and 31 deletions
|
@ -1981,15 +1981,15 @@ evaluated will force it to evaluate again, repeating the query.
|
|||
Also, use of ``iterator()`` causes previous ``prefetch_related()`` calls to be
|
||||
ignored since these two optimizations do not make sense together.
|
||||
|
||||
.. warning::
|
||||
Some Python database drivers still load the entire result set into memory, but
|
||||
won't cache results after iterating over them. Oracle and :ref:`PostgreSQL
|
||||
<postgresql-server-side-cursors>` use server-side cursors to stream results
|
||||
from the database without loading the entire result set into memory.
|
||||
|
||||
Some Python database drivers like ``psycopg2`` perform caching if using
|
||||
client side cursors (instantiated with ``connection.cursor()`` and what
|
||||
Django's ORM uses). Using ``iterator()`` does not affect caching at the
|
||||
database driver level. To disable this caching, look at `server side
|
||||
cursors`_.
|
||||
.. versionchanged:: 1.11
|
||||
|
||||
PostgreSQL support for server-side cursors was added.
|
||||
|
||||
.. _server side cursors: http://initd.org/psycopg/docs/usage.html#server-side-cursors
|
||||
|
||||
``latest()``
|
||||
~~~~~~~~~~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue