-
-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Discussed in https://github.com/orgs/supabase/discussions/20775
Originally posted by nsbradford January 26, 2024
For reference:
- asyncpg uses prepared statements despite they're disabled MagicStack/asyncpg#1058
- Feature request: 'get_attributes' without prepared statements MagicStack/asyncpg#837
- Using statement_cache_size asyncpg setting / prepared statement name for asyncpg w pgbouncer sqlalchemy/sqlalchemy#6467
TLDR: asyncpg is go-to Postgres client, but it has incompatibility with pgbouncer because of issues with prepared statements. Supabase uses it's own in-house Supavisor, but still seems to have the same issue.
There are workarounds if you have access to the pgbouncer instance, but there doesn't seem to be a way to configure Supavisor easily? Are there any other workarounds for this?
Workaround details: https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#prepared-statement-name
To prevent a buildup of useless prepared statements in your application, it’s important to use the NullPool pool class, and to configure PgBouncer to use DISCARD when returning connections. The DISCARD command is used to release resources held by the db connection, including prepared statements. Without proper setup, prepared statements can accumulate quickly and cause performance issues.