]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Cache asyngpg prepared statements
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 1 Jan 2021 18:21:55 +0000 (13:21 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 3 Jan 2021 03:09:39 +0000 (22:09 -0500)
commitdd41a5e61a30a2d05ee09f583fdfde1f1c204807
tree0d03b3f15c3b76ad3c0da5a75ddf524b326d58e2
parent1c35a3790c1f186b91d556fb161c1958cbf718bb
Cache asyngpg prepared statements

Enhanced the performance of the asyncpg dialect by caching the asyncpg
PreparedStatement objects on a per-connection basis. For a test case that
makes use of the same statement on a set of pooled connections this appears
to grant a 10-20% speed improvement.  The cache size is adjustable and may
also be disabled.

Unfortunately the caching gets more complicated when there are
schema changes present.  An invalidation scheme is now also added
to accommodate for prepared statements as well as asyncpg cached OIDs.
However, the exception raises cannot be prevented if DDL has changed
database structures that were cached for a particular asyncpg
connection.  Logic is added to clear the caches when these errors occur.

Change-Id: Icf02aa4871eb192f245690f28be4e9f9c35656c6
doc/build/changelog/unreleased_14/asyncpg_prepared_cache.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/asyncpg.py
test/dialect/postgresql/test_async_pg_py3k.py [new file with mode: 0644]
test/engine/test_execute.py