Connection pooling
Learn how to use connection pooling with your Prisma Postgres database.
Connection pooling keeps a set of database connections open and reuses them across requests, rather than opening a new connection for every query. This reduces latency and lets your database handle more concurrent requests. This is especially important in serverless and high-traffic environments where connection limits can be exhausted quickly.
Prisma Postgres supports connection pooling through TCP connections. You can also use Prisma Accelerate for connection pooling with additional features like caching.
Connection pooling with TCP
TCP connection pooling is currently in Early Access.
To use a pooled connection, append &pooled=true to your Prisma Postgres TCP connection string:
# Direct connection (no pooling)
DATABASE_URL="postgres://USER:PASSWORD@db.prisma.io:5432/?sslmode=require"
# Pooled connection
DATABASE_URL="postgres://USER:PASSWORD@db.prisma.io:5432/?sslmode=require&pooled=true"You can also enable connection pooling when generating your connection string in the Prisma Console by toggling on the pooling option.
This works with any PostgreSQL client, ORM, or database tool you already use.
Connection limits
The number of available connections depends on your plan and whether you use a pooled or direct connection:
| Free | Starter | Pro | Business | |
|---|---|---|---|---|
| Direct connections | 10 | 10 | 50 | 100 |
| Pooled connections | 10 | 100 | 500 | 1000 |
Idle connections are closed after 60 minutes. You can compare plans on the Prisma pricing page.
With TCP connections, there are no limits on query duration, transaction duration, or response size.
When to use pooled vs. direct connections
| Direct | Pooled | |
|---|---|---|
| How it works | Your app connects straight to the database | Your app connects through a managed connection pooler |
| Best for | Local development, background jobs, low-concurrency workloads | Serverless functions, APIs, high-traffic or bursty workloads |
| Typical usage | Long-lived connections | Short-lived or burst connections |
For most production applications, pooled connections are recommended. Use direct connections when you need a persistent connection or are working in a low-concurrency environment like local development.
Connection pooling with Accelerate
You can also connect to your Prisma Postgres database through Prisma Accelerate, which provides built-in connection pooling along with a global caching layer.
Accelerate uses a proxy-based approach and requires Prisma ORM with the Accelerate client extension:
import { PrismaClient } from "../generated/prisma/client";
import { withAccelerate } from "@prisma/extension-accelerate";
const prisma = new PrismaClient({
accelerateUrl: process.env.DATABASE_URL,
}).$extends(withAccelerate());Your Accelerate connection string uses the prisma+postgres:// protocol:
DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=API_KEY"Configurable limits
When connected via Accelerate, connection pool size, query duration, transaction duration, and response size have default limits that you can adjust from the Settings tab in your Prisma Postgres project in the Prisma Console.
Connection pool size
| Free | Starter | Pro | Business | |
|---|---|---|---|---|
| Connection limit | 10 | 100 | 500 | 1000 |
Query timeout
| Free | Starter | Pro | Business | |
|---|---|---|---|---|
| Query timeout | Up to 10 seconds | Up to 10 seconds | Up to 20 seconds | Up to 60 seconds |
If your queries regularly take longer than 10 seconds, consider optimizing them. Long-running queries can indicate missing indexes or inefficient data access patterns. See the error reference for more details.
Interactive transaction timeout
| Free | Starter | Pro | Business | |
|---|---|---|---|---|
| Transaction timeout | Up to 15 seconds | Up to 15 seconds | Up to 30 seconds | Up to 90 seconds |
When you increase the transaction timeout in the Prisma Console, you must also set a matching timeout in your application code:
await prisma.$transaction(
async (tx) => {
// Your queries here
},
{
timeout: 30000, // 30s — must match your Console setting
},
);Response size
| Free | Starter | Pro | Business | |
|---|---|---|---|---|
| Response size | Up to 5 MB | Up to 5 MB | Up to 10 MB | Up to 20 MB |
See the error reference and pricing page for more information.