# What is serverless Postgres, and when should I use it? Serverless Postgres is PostgreSQL you use through a connection string while the provider scales it, pools connections and bills for usage. Prisma Postgres works this way: managed PostgreSQL with pooling on every plan and a serverless driver for edge runtimes. By [Martin Janse van Rensburg](https://github.com/vanrensbird) · 2026-11-24 · 7 min read Pick serverless Postgres when your traffic is uneven, your code runs in serverless or edge functions, or you need many small databases, such as one per preview branch or agent task. Pick an always-on server you size yourself when the query load is heavy and constant, or when your workload depends on long-lived sessions. :::note We make Prisma Postgres, Prisma ORM and Prisma Compute. Every Prisma Postgres claim on this page links to the Prisma docs, checked in November 2026. ::: ## What makes Postgres serverless? Serverless Postgres is a PostgreSQL database you reach through a connection string, while the provider runs the servers, scales them and handles connections for you. Compared with a server you size yourself: | | Serverless Postgres | A server you size yourself | | --- | --- | --- | | Capacity | Scales with your queries. There is no instance to pick or resize. | You pick CPU and memory up front, and resize when traffic grows. | | Connections | A pooler in front of the database lets many function copies share a few real connections. | Each copy of your app opens its own connections. You add and run a pooler yourself. | | Billing | You pay for usage. | You pay for the machine while it runs, busy or idle. | To your app it is ordinary Postgres. Prisma ORM, `node-postgres`, `psql` and other Postgres clients all connect with the same connection string. ## How Prisma Postgres works for serverless and edge apps [Prisma Postgres](/docs/postgres) is managed PostgreSQL that autoscales, so there is no instance to size or upgrade. It bills by operations and storage, where an [operation](/docs/postgres/faq#what-is-an-operation) is one query, read or write. Every database has a pooled connection string, a direct one, and a serverless driver for runtimes without TCP: How apps reach Prisma Postgres: serverless functions and Prisma Compute apps → `pooled.db.prisma.io` (PgBouncer, transaction mode, TCP port 5432). Edge runtimes → serverless driver over HTTP and WebSockets. Migrations, Prisma Studio and `pg_dump` → `db.prisma.io` (direct connection, session state kept). All three reach one PostgreSQL database in the region you chose. ### Connection pooling is built in Application traffic goes to the pooled host, `pooled.db.prisma.io`. It routes through a tenant-isolated PgBouncer instance in transaction mode: a real database connection is assigned for one transaction, then returned to the pool. Many short-lived functions share those connections instead of opening one each. Pooled connection limits depend on the plan: 10 on Free, 100 on Starter, 500 on Pro and 1,000 on Business. The [connection pooling docs](/docs/postgres/database/connection-pooling) cover the pooler in detail. ### Direct connections for migrations and tools The direct host, `db.prisma.io`, skips the pooler. Use it for migrations, Prisma Studio, `pg_dump` and anything that needs session state, such as `LISTEN` and `NOTIFY`. [Connecting to your database](/docs/postgres/database/connecting-to-your-database) shows both formats. ### A serverless driver for edge runtimes Some runtimes can't open a PostgreSQL TCP connection. For those, the [serverless driver](/docs/postgres/database/serverless-driver), `@prisma/ppg`, talks to Prisma Postgres over HTTP and WebSockets. It takes your direct connection string as its credential but never opens a TCP connection: ```ts title="src/query.ts" import { prismaPostgres, defaultClientConfig } from "@prisma/ppg"; const ppg = prismaPostgres(defaultClientConfig(process.env.DATABASE_URL!)); type User = { id: number; email: string }; const users = await ppg.sql` SELECT id, email FROM "User" WHERE email = ${"ada@example.com"} `.collect(); ``` ### Regions You choose one of [six regions](/docs/postgres/faq#what-regions-is-prisma-postgres-available-in) when you create a database: San Francisco, North Virginia, Paris, Frankfurt, Tokyo or Singapore. The region can't be changed later. Every query travels from your function to that region and back, so run your functions in or near it. ## How do I set up serverless Postgres with Prisma? Here is the whole path: Prisma ORM to model and query, Prisma Postgres to store, and Prisma Compute to deploy. The code uses [Prisma ORM 8](/docs/orm). Any other Postgres client works the same way with the connection string. ### 1. Define your schema Your models live in a contract file. `npm create prisma@latest` writes one for a new app, and `npx prisma orm init` adds one to an app you already have. ```prisma title="src/prisma/contract.prisma" // use prisma-8 model User { id Int @id @default(autoincrement()) email String @unique name String? } ``` ### 2. Create a database Run [`create-db`](/docs/postgres/npx-create-db) to get a Prisma Postgres database and its connection string in seconds, with no account. Pick one region and use it for both the database and the app: this guide uses `eu-central-1` (Frankfurt) here and in the deploy step. Export the connection string it prints as `DATABASE_URL`, then create the tables: ```bash npx create-db@latest --region eu-central-1 export DATABASE_URL="" npx prisma contract emit npx prisma db init ``` `contract emit` writes the `contract.json` and `contract.d.ts` files your app imports, and `db init` creates the tables in the empty database. The database is deleted after 72 hours unless you open the claim URL from the output and keep it in your workspace. ### 3. Query it from a serverless function For functions on Node.js or Bun, Prisma ORM has a [serverless client](/docs/orm/reference/transactions-and-runtime#serverless-client-on-postgresql). It holds no connection of its own, so you create it once, outside the handler, and open one connection per request with `connect()`. `await using` closes it when the request ends: ```ts title="src/app/api/users/route.ts" import postgresServerless from "@prisma/orm-postgres/serverless"; import { contractFromJson } from "@prisma/orm-postgres/static"; import type { Contract } from "../../../prisma/contract.d"; import contractJson from "../../../prisma/contract.json" with { type: "json" }; const postgres = postgresServerless({ contract: contractFromJson(contractJson) }); export async function GET() { await using db = await postgres.connect({ url: process.env.DATABASE_URL! }); const users = await db.orm.public.User.all(); return Response.json(users); } ``` In production, set `DATABASE_URL` to the pooled connection string from the Console, so every function instance goes through PgBouncer. On a runtime with no TCP support, query with the serverless driver shown above instead. ### 4. Deploy on Prisma Compute [Prisma Compute](/compute) hosts Node.js, Bun and Next.js apps next to Prisma Postgres, in the same project. Add a [Composer declaration](/docs/prisma-compute/deploy) around your server code, then build and deploy. The first deploy creates the project, named after the app your Composer module exports (`my-app` here), in the region you set: ```bash npx prisma auth login npm run build PRISMA_REGION=eu-central-1 npx prisma deploy ``` Then link the directory to that project, store the connection string as a production [environment variable](/docs/compute/environment-variables), and deploy again so the app reads it: ```bash npx prisma project link my-app npx prisma project env add DATABASE_URL=postgres://... --role production npx prisma deploy ``` Variable values are write-only and resolve at deploy time. You can also let the deploy create the database: a `rawPostgres()` dependency in the Composer module provisions a [Prisma Postgres database](/docs/composer/databases) with the app. Compute scales an idle app to zero and closes idle database connections, so keep your app's pool small and ready to reconnect. ## Can coding agents set up serverless Postgres? Yes. Coding agents such as Claude Code, Cursor and Codex can create a Prisma Postgres database without a person signing up first. `npx create-db@latest --json` returns the connection string, the claim URL and the deletion time as JSON, and the [Prisma MCP server](/docs/ai/tools/mcp-server) lets an agent create databases, inspect the schema and run SQL with your Prisma sign-in. ```bash npx create-db@latest --json --region eu-central-1 ``` In [Scope's November 2026 benchmark](https://www.tryscope.com/leaderboard/databases) of AI agents signing up for a database and using it, Prisma Postgres ranked first of 18 providers, with an 88.3% success rate. ## When is serverless Postgres the wrong choice? - **Sustained, heavy query volume.** Billing follows operations, so at a constant high query rate an always-on server can cost less. [Serverless Postgres compared](/blog/serverless-postgres) works through the crossover. - **Long queries and session state on the pooler.** Pooled connections stop queries after 10 minutes and don't keep session state such as `SET` commands, advisory locks or `LISTEN` and `NOTIFY`. Use the direct connection for those. - **Custom database roles.** Prisma Postgres doesn't support `CREATE ROLE`, so per-role access rules have to live in your app. - **Moving between regions.** A database's region is fixed when you create it. Moving means a new database and a copy with `pg_dump` and `pg_restore`. Every Prisma Postgres plan includes connection pooling. The Free plan includes 200,000 operations a month, 2 GB of storage and up to 50 databases, with no credit card. Paid plans add daily backups, more pooled connections and spend limits. Compare them on the [pricing page](/pricing). ## Frequently asked questions ### What is a serverless database? A serverless database is one you use without provisioning or managing servers. The provider handles capacity, scaling and connections, and you pay for what you use rather than for a fixed machine. Serverless Postgres is a serverless database that speaks standard PostgreSQL, so existing Postgres clients and tools work with it. ### Is Prisma Postgres serverless? Yes. There is no instance to size or upgrade, connection pooling is built in, and you pay for operations and storage. Serverless functions connect over the pooled connection string, and edge runtimes connect through the [serverless driver](/docs/postgres/database/serverless-driver). Any Postgres client works, and Prisma ORM is optional. ### Can I use Prisma Postgres from edge runtimes? Yes. On a runtime that can't open a PostgreSQL TCP connection, use the [serverless driver](/docs/postgres/database/serverless-driver), `@prisma/ppg`. It connects over HTTP and WebSockets, with your direct connection string as the credential. ### What is the best serverless Postgres? The one whose billing and idle behaviour match your traffic. Check what you're billed for (queries, compute time or an instance), what happens when the database is idle, how connections are pooled, and whether you can host your app next to it. [Serverless Postgres compared](/blog/serverless-postgres) puts the main options side by side. ## Create a serverless Postgres database Run npx create-db for a Prisma Postgres database and its connection string in seconds, with no account, or sign up and create one in the Console. Any Postgres client works. `npx create-db@latest` [Get started](https://console.prisma.io/sign-up) ## Related guides - [Serverless Postgres compared](/blog/serverless-postgres) - [Prisma Postgres serverless driver](/docs/postgres/database/serverless-driver) - [Prisma Postgres connection pooling and limits](/docs/postgres/database/connection-pooling) - [Traditional databases vs serverless databases](/dataguide/serverless/traditional-vs-serverless-databases) - [Why the first request after idle is slow](/postgres/slow-first-request-after-idle)