#36143: DatabaseOperations.bulk_batch_size() is overly protective on SQLite in
most
cases
-------------------------------------+-------------------------------------
Reporter: Sarah Boyce | Owner: Sage
Type: | Abdullah
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sage Abdullah):
* owner: (none) => Sage Abdullah
* status: new => assigned
Comment:
Note that while there is a compile-time option, the limit can be made
lower for each connection
[https://www.sqlite.org/limits.html#max_variable_number according to the
SQLite docs]:
> The maximum host parameter number can be lowered at run-time using the
`sqlite3_limit(db,SQLITE_LIMIT_VARIABLE_NUMBER,size)` interface.
I just found that Python >= 3.11 introduced the functions
[https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.getlimit
getlimit() and setlimit()] that can be used to get/set these per-
connection limits at run-time. This means we'd probably want it to vary on
each connection, rather than cached on the class. That said, if it's
cached anyway, developers who want to set a different limit on the
connection will have to clear the cache in order for Django to pick it up.
Django 6.0 will require Python 3.12+, so I think we're good to use these
functions. I haven't checked whether this is specific to CPython, though.
There's also an
[https://github.com/python/cpython/blob/285c1c4e9543299c8bf69ceb39a424782b8c632e/Lib/test/test_sqlite3/test_dbapi.py#L886-L893
example usage in the CPython tests].
I'm assigning this to myself so I can hand it over for Djangonaut Space in
the coming weeks, I hope it's okay. That said, please do leave a comment
if you have any opinions on how we should approach this ticket. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/36143#comment:4>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070194d30c9bac-594937da-2fc7-4303-8e31-4be547d8cb8d-000000%40eu-central-1.amazonses.com.