Opened 3 months ago

Last modified 3 months ago

#36420 assigned Cleanup/optimization

Use actual SQLite limits in last_executed_query()

Reported by: Adam Johnson Owned by: myoungjinGo
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Sage Abdullah Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The SQLite backend’s last_executed_query() method does its own parameter batching: https://github.com/django/django/blob/b373721af0e5c3de0986977ac07e3ad55061ecbe/django/db/backends/sqlite3/operations.py#L154-L179

The comment there from Aymeric notes that “Since Python's sqlite3 module doesn't expose the get_limit() C API, assume the default limits are in effect...”.

Python 3.11 added the getlimit() function, which exposes that API: https://docs.python.org/3.13/library/sqlite3.html#sqlite3.Connection.getlimit . We already have use for it in #36143.

That method could be updated to use the actual limits and accurately reflect the queries that were executed.

Change History (5)

comment:1 by Clifford Gama, 3 months ago

Triage Stage: UnreviewedAccepted

Thanks!

comment:2 by Natalia Bidart, 3 months ago

It's worth noting that support for Python 3.10 and 3.11 has been dropped in 6.0 as per #36005 (making this change safe).

comment:3 by myoungjinGo, 3 months ago

Owner: set to myoungjinGo
Status: newassigned

comment:4 by myoungjinGo, 3 months ago

Has patch: set

comment:5 by Sage Abdullah, 3 months ago

Cc: Sage Abdullah added
Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top