mirror of
https://github.com/jackc/pgx.git
synced 2025-07-15 08:40:24 +00:00
Created Automatic Prepared Statement Caching (markdown)
parent
41bdf959d1
commit
e4b9bf8607
13
Automatic-Prepared-Statement-Caching.md
Normal file
13
Automatic-Prepared-Statement-Caching.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Automatic Prepared Statement Caching
|
||||
|
||||
By default pgx automatically prepares and caches queries. pgx also supports manually preparing and executing statements, but it should rarely be necessary.
|
||||
|
||||
While this automatic caching typically provides a significant performance improvement it does impose a restriction that the same SQL query always has the same parameter and result types. Otherwise an error will occur.
|
||||
|
||||
For example, the query `select * from foo` will fail if a column is added or removed to `foo` after the statement is cached.
|
||||
|
||||
This error can also be triggered by cursors that return different result types.
|
||||
|
||||
Another incompatibility is with PgBouncer. PgBouncer does not support prepared statements.
|
||||
|
||||
In any case, statement caching can be disabled by connecting with `statement_cache_capacity=0`.
|
Loading…
x
Reference in New Issue
Block a user