mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +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:
committed by
Tim Graham
parent
53bffe8d03
commit
f3b7c05936
@@ -171,6 +171,24 @@ If you need to add a PostgreSQL extension (like ``hstore``, ``postgis``, etc.)
|
||||
using a migration, use the
|
||||
:class:`~django.contrib.postgres.operations.CreateExtension` operation.
|
||||
|
||||
.. _postgresql-server-side-cursors:
|
||||
|
||||
Server-side cursors
|
||||
-------------------
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
||||
When using :meth:`QuerySet.iterator()
|
||||
<django.db.models.query.QuerySet.iterator>`, Django opens a :ref:`server-side
|
||||
cursor <psycopg2:server-side-cursors>`. By default, PostgreSQL assumes that
|
||||
only the first 10% of the results of cursor queries will be fetched. The query
|
||||
planner spends less time planning the query and starts returning results
|
||||
faster, but this could diminish performance if more than 10% of the results are
|
||||
retrieved. PostgreSQL's assumptions on the number of rows retrieved for a
|
||||
cursor query is controlled with the `cursor_tuple_fraction`_ option.
|
||||
|
||||
.. _cursor_tuple_fraction: https://www.postgresql.org/docs/current/static/runtime-config-query.html#GUC-CURSOR-TUPLE-FRACTION
|
||||
|
||||
Test database templates
|
||||
-----------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user