From 904fb12ad4c1d9855f7df079c9059b3966364c37 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Mon, 6 Nov 2023 14:35:05 +0100 Subject: [PATCH] fix some stuff --- ...nfigure-for-external-connection-pooler.mdx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx b/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx index 63d985ef4b..de89b01c01 100644 --- a/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx +++ b/content/300-guides/100-performance-and-optimization/150-connection-management/200-configure-for-external-connection-pooler.mdx @@ -12,31 +12,31 @@ Usually, this works transparently, but some connection poolers only support a li ## PgBouncer -TODO Note about this only applying to PgBouncer <1.21.0 - ### Set PgBouncer to transaction mode -Additionally, 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 query engine to work with PgBouncer. - -
- How `pgbouncer` mode works in Prisma - -- 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. +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. ### Add pgbouncer=true to the connection URL -To use Prisma Client with PgBouncer from a serverless function, add the `?pgbouncer=true` flag to the PostgreSQL connection URL: +To use Prisma Client with PgBouncer, add the `?pgbouncer=true` flag to the PostgreSQL connection URL: ``` postgresql://USER:PASSWORD@HOST:PORT/DATABASE?pgbouncer=true ``` -> 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. +> 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 also disables any prepared statement or type query caches. + +
### Prisma Migrate and PgBouncer workaround