#27639: Add a chunk size argument to QuerySet.iterator()
-------------------------------------+-------------------------------------
Reporter: François | Owner: nobody
Freitag |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords: cursors database
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Django currently fetches results from the database in batches of
{{{GET_ITERATOR_CHUNK_SIZE}}} (currently 100). When {{{.iterator()}}} is
used, usually for a large query, specifying the batch size would allow
more control over the number of back-and-forth communications between
Django and the database.
[https://www.python.org/dev/peps/pep-0249/#fetchmany PEP249] define the
{{{size}}} argument for the {{{.fetchmany()}}} method.
* MySQL-python provides the [https://dev.mysql.com/doc/connector-python/en
/connector-python-api-mysqlcursor-fetchmany.html size] argument for
{{{.fetchmany()}}}.
* SQLite provides the
[https://docs.python.org/3.6/library/sqlite3.html#sqlite3.Cursor.fetchmany
size] argument for {{{.fetchmany()}}}.
* cx_Oracle provides [http://cx-
oracle.readthedocs.io/en/latest/cursor.html?highlight=arraysize#Cursor.arraysize
arraysize] attribute on the cursor and the [http://cx-
oracle.readthedocs.io/en/latest/cursor.html#Cursor.fetchmany numRows]
argument for {{{.fetchmany()}}}.
* Psycopg2 (used for PostgreSQL) provides the
[http://initd.org/psycopg/docs/cursor.html?highlight=itersize#cursor.itersize
itersize] attribute (used by server-side cursors, see discussion on
[https://github.com/django/django/pull/7587 This PR -- Added server side
cursors support for QuerySet iteration in PostgreSQL].
Note:
In [https://code.djangoproject.com/ticket/26530#comment:3 #26530], Anssi
Kääriäinen proposed the name {{{cursor_size}}} for this argument.
--
Ticket URL: <https://code.djangoproject.com/ticket/27639>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/058.48ab6971aad1c07016871ebad0619534%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.