﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27639	Add a chunk size argument to QuerySet.iterator()	François Freitag	François Freitag	"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."	New feature	closed	Database layer (models, ORM)	dev	Normal	fixed	cursors database	florian@… josh.smeaton@… charettes@… me@…	Accepted	1	0	0	0	0	0
