Disabling Prepared statements

Last edited: 1/17/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:


_10
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:


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

Node postgres

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


_10
const query = {
_10
name: 'fetch-user', // <--------- DO NOT INCLUDE
_10
text: 'SELECT * FROM user WHERE id = $1',
_10
values: [1],
_10
}

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: