Disabling Prepared statements

Last edited: 2/4/2025

It is important to note that although the direct connections and Supavisor in session mode support prepared statements, Supavisor in transaction mode does not.#

How to disable prepared statements for Supavisor in transaction mode#

Each ORM or library configures prepared statements differently. Here are settings for some common ones. If you don't see yours, make a comment

Prisma:

add ?pgbouncer=true to end of connection string:

1
postgres://[db-user].[project-ref]:[db-password]@aws-0-[aws-region].pooler.supabase.com:6543/[db-name]?pgbouncer=true

Drizzle:

Add a prepared false flag to the client:

1
export const client = postgres(connectionString, { prepare: false })

Node Postgres

Just omit the "name" value in a query definition:

1
const = {
2
: 'fetch-user', // <--------- DO NOT INCLUDE
3
: 'SELECT * FROM user WHERE id = $1',
4
: [1],
5
}

Psycopg

set the prepare_threshold to None.

asyncpg

Follow the recommendation in the asyncpg docs

disable automatic use of prepared statements by passing statement_cache_size=0 to asyncpg.connect() and asyncpg.create_pool() (and, obviously, avoid the use of Connection.prepare());

Rust's Deadpool or tokio-postgres: