Skip to content

How to use supavisor with asyncpg? #287

@awalias

Description

@awalias

Discussed in https://github.com/orgs/supabase/discussions/20775

Originally posted by nsbradford January 26, 2024
For reference:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions