Opened 10 years ago
Last modified 10 years ago
#23292 closed Bug
ATOMIC_REQUESTS creates unnecessary database connections and transactions — at Initial Version
Reported by: | ijl | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.6 |
Severity: | Normal | Keywords: | atomic_requests, database, transactions |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When specifying ATOMIC_REQUESTS
on a database, a connection is made to the database whether or not it is used. This is due to BaseHandler.make_view_atomic
wrapping the view in a transaction.atomic
for each database. Each call to transaction.atomic
results in opening a database connection and then opening a transaction.
This is a serous performance regression for a project migrated from using TransactionMiddleware
with many databases. The previous behavior was that a connection and transaction would be opened only for a database that the ORM needed to access.
Is there any interest in modifying this to acquire connections and transactions lazily?