Written by Huifer
I did not run a controlled benchmark that can honestly declare one database the universal winner. Instead, I built this comparison around the deployment boundaries I use when evaluating SaaS architecture: where code runs, which SQL features the product needs, how environments are isolated, and what operational work remains. The goal is a defensible choice, not a fabricated latency or cost claim.
Verification: TanStack · Cloudflare D1 documentation · PlanetScale documentation · Neon documentation · web.dev
Last updated: 2026-10-24 · Changelog
TL;DR
- Choose Cloudflare D1 when your application already runs on Workers and needs a lightweight SQLite database close to that runtime.
- Choose PlanetScale when MySQL compatibility, schema workflows, and branch-based database development are the deciding constraints.
- Choose Neon when you want serverless Postgres, database branching, and a broader PostgreSQL ecosystem.
- Do not choose from a static price headline: quotas, regions, compute behavior, and feature availability change. Verify the current Cloudflare D1 pricing, PlanetScale pricing, and Neon pricing pages before committing.
Standalone answer: Cloudflare D1 is the most natural fit for a Worker-first SaaS with SQLite-compatible access patterns. PlanetScale is a strong MySQL platform for teams that value safe schema workflows, while Neon is the better match when PostgreSQL compatibility and its surrounding ecosystem are more important than colocating every request with Workers.
This article is for a founder or small team choosing a database for a new SaaS, especially one considering Cloudflare Workers or TanStack Start. The decision is which SQL and operational boundary creates the fewest surprises? Start with the SaaS boilerplate decision guide if you also need to compare starting points.
Cloudflare D1 vs PlanetScale vs Neon: the short answer
The three products solve related problems but have different boundaries.
| Decision factor | Cloudflare D1 | PlanetScale | Neon |
|---|---|---|---|
| Primary model | SQLite | MySQL-compatible | PostgreSQL-compatible |
| Natural runtime fit | Cloudflare Workers | Hosted or serverless runtimes | Hosted or serverless runtimes |
| Strongest reason to choose | Worker-native access and SQLite simplicity | MySQL workflows and schema branches | PostgreSQL compatibility and ecosystem breadth |
| Main boundary to verify | SQLite limits and write topology | Driver, transaction, and compatibility behavior | Connection lifecycle and Postgres operations |
My rule is simple: start with database semantics, then optimize deployment location. “Edge” does not make a write-heavy workflow globally conflict-free, branching does not make every MySQL feature portable, and Postgres compatibility does not remove connection-management work.
Who should choose each database?
Choose D1 when the application already runs on Workers and its schema fits SQLite. Choose PlanetScale when MySQL compatibility and branch-based schema development are central to the team’s workflow. Choose Neon when PostgreSQL features, extensions, or existing tooling are requirements. Verify each decision against D1 limits, PlanetScale branching, and Neon architecture. A small proof-of-concept is still necessary.
Compare the database semantics before the hosting model
The most expensive database decision is often made in an ORM schema file before anyone writes down SQL assumptions. Start by listing the queries that define the product.
SQLite, MySQL, and PostgreSQL are not interchangeable
An ORM can make three databases look similar while types, indexes, locking, search, JSON operations, extensions, and migrations differ. Validate D1 against the SQLite language reference, PlanetScale against the MySQL reference, and Neon against the PostgreSQL documentation.
Problem: A schema works locally with SQLite but fails when a production query assumes a PostgreSQL-specific operator.
Root cause: The local development database was treated as an interchangeable mock rather than the same SQL contract used in production.
Solution: Run representative migrations and queries against the target provider in CI, including constraints, indexes, search, and transaction boundaries.
Result: The measurable outcome is a smaller compatibility gap before launch, not a guaranteed performance gain.
Branching is a workflow feature, not a database engine
PlanetScale and Neon make branching part of their workflows, but a branch does not automatically test production-sized data, jobs, permissions, or every query. D1 has its own migration workflow. Before committing, document the schema source of truth, destructive-change review, preview data, and restore path.
Runtime fit: Workers, connection behavior, and edge deployment
Cloudflare D1 has an unusually direct relationship with Cloudflare Workers. A Worker can access D1 through a binding, which keeps the application’s database call inside the platform’s request model. The Workers bindings documentation is the right place to verify the current API shape.
A minimal D1 access pattern looks like this:
// @cloudflare/workers-types: verify the version used by your project
interface Env {
DB: D1Database
}
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url)
const accountId = url.searchParams.get("account")
if (!accountId) return new Response("Missing account", { status: 400 })
const row = await env.DB
.prepare("select id, name from accounts where id = ?1")
.bind(accountId)
.first()
return Response.json(row ?? null)
},
}
This proves only that the access model is compact. It does not prove that D1 fits concurrent writes, cross-region coordination, or non-SQLite features.
PlanetScale and Neon are usually connected through a client or driver rather than a native Worker binding. That can still work well, but the connection path becomes part of the design. Review Cloudflare’s database connectivity guidance and the provider-specific serverless driver documentation before putting a long-lived connection assumption into an isolate-based runtime.
For Neon, the serverless driver documentation is especially relevant to edge functions. For PlanetScale, review the serverless driver guide and confirm whether your framework, ORM, and transaction requirements are supported.
// Pseudocode: keep provider access behind an application boundary
export async function getAccount(id: string) {
const result = await database.query(
"select id, name from accounts where id = $1",
[id],
)
return result.rows[0] ?? null
}
Placeholder syntax differs by driver; use the provider’s documented API.
A connection checklist for non-D1 providers
Before choosing PlanetScale or Neon for a Worker-oriented SaaS, verify:
- The driver supports the runtime without Node-only APIs.
- The ORM’s connection behavior is explicit.
- Transactions, timeouts, retries, and provider errors are observable.
Before: Treating a serverless database as a drop-in replacement for an in-process binding can hide connection, timeout, and transaction assumptions.
After: A small runtime proof-of-concept exercises one read, one transaction, one migration, and one failure path before the full template is selected.
Verification: Run the proof-of-concept in the same deployment target and inspect provider logs plus application traces. No universal latency number should be claimed without that workload-specific test.
Which database fits common SaaS features?
The decision changes with the feature being built. A marketing site, dashboard, and billing system do not have the same requirements.
Authentication and tenant records
All three can represent users, organizations, memberships, roles, and settings if the SQL model and auth integration support them. The key issue is tenant isolation: every query needs an organization boundary enforced in application code, database policy, or both. Treat auth and data as separate decisions; a database is not automatically an identity layer.
Billing and webhook state
Billing workflows need idempotency keys, durable event state, unique constraints, and a clear retry policy. Stripe’s webhook best practices should be part of the evaluation regardless of database provider.
Problem: A webhook handler records an event after performing an external side effect, then retries create a duplicate state transition.
Root cause: The database schema lacks a unique event identifier or the handler does not make the state transition idempotent.
Solution: Store the provider event ID under a unique constraint, verify the signature, and make processing repeatable.
Result: Verify duplicate-event behavior with a deterministic test; do not infer payment reliability from a marketing page.
A Worker-first application can store this state in D1, but still needs transaction and write-contention tests. Postgres or MySQL requires the same idempotency design.
Search, analytics, and reporting
Search and reporting are where a simple relational database grows more complex. D1 may suit structured filters and ordinary indexes, but FTS, analytical scans, and large aggregations need a workload test. PlanetScale and Neon may offer more familiar tooling, but neither turns transactional storage into an analytics warehouse.
For a SaaS template, ask whether the data layer supports the expected reporting surface. Unclear migrations, backups, and observability can cost more than fewer screens.
Decision matrix: choose by constraint, not popularity
Use this checklist as a practical tie-breaker:
| If your strongest constraint is… | Start with… | Verify before committing |
|---|---|---|
| Workers-native deployment | Cloudflare D1 | SQLite compatibility, write topology, backups, limits |
| MySQL ecosystem and schema branches | PlanetScale | Driver support, transactions, compatibility, current pricing |
| PostgreSQL extensions or tooling | Neon | Connection lifecycle, pooling, compute behavior, extensions |
| Global writes with strict coordination | None by default | Model conflict resolution and consistency explicitly |
| Heavy analytics | None by default | Separate transactional and analytical workloads |
Before: Selecting a provider from a “fastest database” list creates a decision without a workload, region, query shape, or consistency requirement.
After: Selecting from a written constraint matrix makes the trade-off inspectable by the rest of the team.
Verification: Review ten representative queries, two migration paths, one failure path, and one restore path. Record measured results separately from estimates and vendor documentation.
Which SaaS template fits this database decision?
Check the database choice against the template’s runtime. Browse the TanStack templates and inspect whether the starting point assumes Workers, hosted Postgres, MySQL compatibility, or a separate adapter.
The buyer question is: does the template reduce integration work without hiding the database boundary? Look for:
- A schema and migration process you can run locally and in preview environments.
- Explicit environment variables or bindings for the chosen runtime.
- Tests for authentication, tenancy, billing events, and failed database calls.
- Documentation for backups, restore, observability, and provider limits.
- A clear path to replace the default database adapter if product requirements change.
A template can accelerate routing, auth, billing, and deployment, but it cannot decide whether the workload fits SQLite, MySQL, or PostgreSQL. See the Cloudflare D1 production guide.
Limitations and evidence boundaries
This is a decision guide, not a vendor benchmark. I have not claimed latency, savings, throughput, or a universal winner because those require a defined workload and current measurements. Verify pricing and limits on the official pages.
The comparison does not cover self-hosted PostgreSQL, warehouses, vector search, or compliance review. “Edge” is placement, not a promise of conflict-free writes.
Provider capabilities are documented when linked to official references; recommendations are editorial; proof-of-concept results are measured; projected cost or traffic is estimated until tested. Your workload may differ.
FAQ: Cloudflare D1 vs PlanetScale vs Neon
Is Cloudflare D1 better than PlanetScale for a SaaS?
D1 is better when the SaaS is already built for Cloudflare Workers and its schema fits SQLite semantics. PlanetScale is better when MySQL compatibility, branch-based schema development, or an existing MySQL toolchain matters more. Neither is universally better; compare the required queries, migrations, transaction behavior, and deployment runtime first.
Is Neon better than D1 for PostgreSQL applications?
Usually, Neon is the more direct fit when PostgreSQL compatibility, extensions, or Postgres-specific tooling is a hard requirement. D1 may be simpler for a Worker-native application, but moving a Postgres-oriented schema to SQLite can create translation work. Confirm the ORM, query operators, indexes, and transaction requirements before migrating.
Can Cloudflare D1 handle a multi-tenant SaaS?
D1 can model tenants, memberships, and scoped records, but the provider does not remove the need for tenant isolation. Every read and write needs an organization boundary, and billing or administrative changes need careful transaction and idempotency tests. Validate limits, write contention, backups, and restore procedures against your actual workload.
Conclusion: make the database decision explicit
Choose Cloudflare D1 for a Worker-first SaaS that fits SQLite, PlanetScale for MySQL workflows, and Neon when PostgreSQL is non-negotiable. Next, write ten representative queries, run a small proof-of-concept in the intended runtime, and compare SaaS templates and boilerplates. Then preview the available templates.
Disclosure: I have no material connection to Cloudflare, PlanetScale, or Neon for this article. This post does not contain affiliate claims, customer results, or vendor-funded benchmarks. If a provider changes its limits or documentation, contact the author through the about page so the comparison can be corrected.