PlanetScale Postgres
PlanetScale Postgres
The generated project uses pg with drizzle-orm/node-postgres. Tables use drizzle-orm/pg-core.
| Connection | Variable | Endpoint |
|---|---|---|
| Application queries | DATABASE_URL |
PgBouncer, port 6432 |
| Migrations and Studio | DATABASE_URL_DIRECT |
Direct, port 5432 |
Copy TLS-enabled connection strings from PlanetScale and keep sslmode=verify-full. Give each connection role the permissions it needs.
Connection pooling
The application reuses one pg.Pool per process and database environment. It registers the pool with Vercel’s attachDatabasePool for idle connection cleanup.
Default limits in src/db/connection.ts:
| Setting | Default |
|---|---|
| Maximum connections per instance | 5 |
| Connection/acquisition timeout | 5 seconds |
| Idle timeout in production | 5 seconds |
| Idle timeout in development | 10 seconds |
The connection timeout does not limit query duration. Size the pool for your database capacity and number of live instances; measure before reducing it. Longer idle timeouts also extend Vercel’s cleanup window.
Keep the existing pool across requests. Drizzle acquires/releases clients for queries and transactions. If you use pool.connect() directly, release its client in finally.
See node-postgres pool sizing and Vercel connection pooling. Enable Fluid Compute in Vercel’s project settings when using it.