Choosing a database: D1 vs Postgres vs SQLite
How to pick among the three databases beginners meet most: what each suits, how the free tier works, and how not to overthink it.
In one sentence
SQLite is simplest, Postgres is most capable, D1 fits Cloudflare best. For most beginner projects, just pick the simplest one that works.
What you'll build
A clear call on which database your project should use and why — no more choice paralysis.
The conclusion first
Don't agonize over a new project: pick the one that's simplest while still meeting your needs. There's no absolute best database, only a fit for where you are now.
The one-line difference
- SQLite: a single file is the whole database — zero setup, super simple, runs right next to your code.
- PostgreSQL: the most complete, the most widely used, the biggest ecosystem — scales from tiny to very large.
- D1: Cloudflare's SQLite-based cloud database, integrates seamlessly with Pages/Workers, with a friendly free tier.
Side by side
| Dimension | SQLite | PostgreSQL | D1 |
|---|---|---|---|
| Ease of use | Lowest | Medium | Low (if you know SQLite) |
| Suited scale | Small to medium | Small to very large | Small to medium (growing) |
| Deployment | Bundled with the app | Needs a database server | Native on Cloudflare |
| Free | Free by nature | Depends on your host | Has a free tier |
| Cloudflare fit | No direct integration | External | Native, smoothest |
How to choose
- Pure learning or a local tool → SQLite.
- Deploying on Cloudflare and want one stack → D1.
- Complex queries, heavy concurrent writes, or the most mature ecosystem → PostgreSQL.
Good news: they're a lot alike
All three are SQL databases, and the basic "create table, query, insert, update" syntax is largely shared (D1 is SQLite). So start with the simple one; if you genuinely outgrow it, moving is less scary than you'd think — but it isn't free either, so spending five minutes to pick the right scale up front is still worth it.
Next steps
- Shore up the concept: Database
- Nail down the table design: Design a database with AI
- See each database in detail: Databases
Frequently asked questions
As a beginner unsure which to use, what’s the safest default?
Pick the one that’s simplest while meeting your needs: SQLite for pure learning or a local tool; D1 if you’re deploying on Cloudflare (if you know SQLite, you know it). Reach for PostgreSQL only when you need complex queries, heavy concurrent writes, or the most mature ecosystem.
If my data grows, will switching databases hurt?
All three are SQL with largely shared syntax (D1 *is* SQLite), so a move is less scary than you’d think — but not free either: data migration, syntax differences and downtime all need handling. So picking the right "scale" up front beats moving later — worth five minutes of thought.
References
- Cloudflare D1 Documentation — Cloudflare
- PostgreSQL Documentation — PostgreSQL Global Development Group
- SQLite Documentation — SQLite