diff --git a/cSpell.json b/cSpell.json
index ce34b4139f..1de4ee7a95 100644
--- a/cSpell.json
+++ b/cSpell.json
@@ -89,6 +89,7 @@
"libgcc",
"libc",
"Distroless",
+ "Supavisor",
"inshellisense",
],
"patterns": [
diff --git a/content/300-guides/025-migrate/100-developing-with-prisma-migrate/200-troubleshooting-development.mdx b/content/300-guides/025-migrate/100-developing-with-prisma-migrate/200-troubleshooting-development.mdx
index 60d1e8b94e..8d4d1202b2 100644
--- a/content/300-guides/025-migrate/100-developing-with-prisma-migrate/200-troubleshooting-development.mdx
+++ b/content/300-guides/025-migrate/100-developing-with-prisma-migrate/200-troubleshooting-development.mdx
@@ -134,4 +134,4 @@ Error: undefined: Database error
Error querying the database: db error: ERROR: prepared statement "s0" already exists
```
-See [Prisma Migrate and PgBouncer workaround](/guides/performance-and-optimization/connection-management/configure-pg-bouncer) for further information and a workaround. Follow [GitHub issue #6485](https://github.com/prisma/prisma/issues/6485) for updates.
+See [Prisma Migrate and PgBouncer workaround](/guides/performance-and-optimization/connection-management/configure-pg-bouncer) for further information and a workaround.
diff --git a/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-pg-bouncer.mdx b/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx
similarity index 55%
rename from content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-pg-bouncer.mdx
rename to content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx
index f30fbb9131..2d818122cf 100644
--- a/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-pg-bouncer.mdx
+++ b/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx
@@ -1,38 +1,44 @@
---
-title: Configure Prisma Client with PgBouncer
+title: Configure Prisma Client with an external connection pooler (like PgBouncer)
---
-PgBouncer holds a connection pool to the database and proxies incoming client connections by sitting between Prisma Client and the database. This reduces the number of processes a database has to handle at any given time. PgBouncer passes on a limited number of connections to the database and queues additional connections for delivery when space becomes available.
+An external connection pooler like PgBouncer holds a connection pool to the database, and proxies incoming client connections by sitting between Prisma Client and the database. This reduces the number of processes a database has to handle at any given time.
+
+Usually, this works transparently, but some connection poolers only support a limited set of functionality. One common feature that external connection poolers do not support are named prepared statements, which Prisma uses. For these cases, Prisma can be configured to behave differently.
-## Add pgbouncer to the connection URL
+## PgBouncer
-To use Prisma Client with PgBouncer from a serverless function, add the `?pgbouncer=true` flag to the PostgreSQL connection URL:
+### Set PgBouncer to transaction mode
-```
-postgresql://USER:PASSWORD@HOST:PORT/DATABASE?pgbouncer=true
-```
+For Prisma Client to work reliably, PgBouncer must run in [**Transaction mode**](https://www.pgbouncer.org/features.html).
+
+Transaction mode offers a connection for every transaction – a requirement for the Prisma Client to work with PgBouncer.
-> Note: `PORT` specified for PgBouncer pooling sometimes different from the default `5432` port. Check database provider docs for the exact port number, otherwise adding `?pgbouncer=true` won't work.
+### Add pgbouncer=true to the connection URL
-## Set PgBouncer to transaction mode
+To use Prisma Client with PgBouncer, add the `?pgbouncer=true` flag to the PostgreSQL connection URL:
-Additionally, for Prisma Client to work reliably, PgBouncer must run in [**Transaction mode**](https://www.pgbouncer.org/features.html).
+```
+postgresql://USER:PASSWORD@HOST:PORT/DATABASE?pgbouncer=true
+```
-_Transaction mode_ offers a connection for every transaction – a requirement for the Prisma query engine to work with PgBouncer.
+> Note: `PORT` specified for PgBouncer pooling is sometimes different from the default `5432` port. Check your database provider docs for the correct port number.
How `pgbouncer` mode works in Prisma
+- Prisma opens a transaction for every query – even when just reading data, allowing Prisma to use prepared statements.
+- Prisma does not try to set the `search_path`, which is not supported by PgBouncer.
- Prisma cleans up already present prepared statements in the connection by running `DEALLOCATE ALL` before preparing and executing Prisma Client queries.
-- Prisma opens a transaction for every query case – even when just reading data, allowing Prisma to use prepared statements.
+- Prisma also disables any prepared statement or type query caches.
-## Prisma Migrate and PgBouncer workaround
+### Prisma Migrate and PgBouncer workaround
Prisma Migrate uses **database transactions** to check out the current state of the database and the migrations table. However, the Schema Engine is designed to use a **single connection to the database**, and does not support connection pooling with PgBouncer. If you attempt to run Prisma Migrate commands in any environment that uses PgBouncer for connection pooling, you might see the following error:
@@ -57,7 +63,7 @@ The block above uses a PgBouncer connection string as the primary URL using `url
It also provides a connection string directly to the database, without PgBouncer, using the `directUrl` field. This connection string will be used when [commands that require a single connection](/data-platform/classic-projects/data-proxy/prisma-cli-with-data-proxy#prisma-cli-commands-that-require-a-direct-database-connection) to the database, such as `prisma migrate dev` or `prisma db push`, are invoked.
-## PgBouncer with different database providers
+### PgBouncer with different database providers
There are sometimes minor differences in how to connect directly to a Postgres database that depend on the provider hosting the database.
@@ -65,3 +71,11 @@ Below are links to information on how to set up these connections with providers
- [Connecting directly to a PostgreSQL database hosted on Digital Ocean](https://github.com/prisma/prisma/issues/6157)
- [Connecting directly to a PostgreSQL database hosted on ScaleGrid](https://github.com/prisma/prisma/issues/6701#issuecomment-824387959)
+
+## Supabase Supavisor
+
+Supabase's Supavisor behaves similar to [PgBouncer](#pgbouncer). You can add `pgbouncer=true` to your connection pooled connection string.
+
+## Other external connection poolers
+
+Although Prisma does not have explicit support for other connection poolers, if the limitations are similar to the ones of [PgBouncer](#pgbouncer) you can usually also use `pgbouncer=true` in your connection string to put Prisma in a mode that works with them as well.
diff --git a/vercel.json b/vercel.json
index 3eb266760a..9d1396a39f 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1716,13 +1716,17 @@
"destination": "/docs/data-platform/platform-console/support"
},
{
- "source": "/docs/data-platform/accelerate/testing",
- "destination": "/docs/data-platform/accelerate/evaluating"
+ "source": "/docs/guides/performance-and-optimization/connection-management/configure-pg-bouncer",
+ "destination": "/docs/guides/performance-and-optimization/connection-management/configure-for-external-connection-pooler"
},
{
"source": "/docs/data-platform/classic-projects/platform/billing",
"destination": "https://www.prisma.io/pricing"
},
+ {
+ "source": "/docs/data-platform/accelerate/testing",
+ "destination": "/docs/data-platform/accelerate/evaluating"
+ },
{
"source": "/docs/data-platform/classic-projects/platform/billing/plans-and-quotas",
"destination": "https://www.prisma.io/pricing"