Edge databases explained: what Cloudflare D1 means for your app's speed and cost

What 'SQLite at the edge' actually means, where Cloudflare D1 beats a traditional database, where it falls over, and how it changes build and run costs.

Most application databases spend their lives waiting. A server sits in a rack in northern Virginia, powered on around the clock, holding a few hundred megabytes of customer records, and answers maybe four hundred queries an hour. You pay for the rack time, not the queries.

Edge databases invert that. Cloudflare D1 is the one we reach for most, and the short version is: it’s SQLite, run as a managed service on Cloudflare’s network, billed by what you actually read and write. That change sounds small. It moves both the speed math and the cost math for a normal business app.

Here’s what’s actually going on, where it helps, and where it’s the wrong tool.

What “SQLite at the edge” actually means

SQLite is not a toy. It’s the most widely deployed database engine in existence — it’s in every iPhone, every Android phone, every browser, most desktop software, and a great many airplanes. It’s been in continuous development since 2000, it has an aviation-grade test suite, and it’s public domain.

What makes it different from Postgres or MySQL is that it isn’t a server. There’s no daemon listening on a port, no connection pool, no authentication handshake. It’s a library that reads and writes a single file. Your code and your data live in the same process.

D1 takes that model and runs it on Cloudflare’s network. You still write ordinary SQL:

  • CREATE TABLE, SELECT, JOIN, GROUP BY, indexes, foreign keys, transactions
  • Migrations as plain .sql files, versioned in your repo
  • A schema you could hand to any SQL developer and have them understand in a minute

What you don’t do is size an instance, pick a region, configure a connection pool, tune max_connections, or pay for the hours when nobody visits.

Why this arrangement works now and didn’t before

Two things had to be true. First, the compute had to move — Cloudflare Workers run your application code in hundreds of cities rather than one region, so there’s an “edge” for the database to sit next to. Second, D1 had to grow up: read replication, real migrations, backup and point-in-time restore, a stable API, and a sessions model that keeps reads consistent for a given user. By 2026 those exist. Five years ago the honest answer was “not yet.”

The three things that actually change

Speed is about round trips, not query time

Here’s the part most people get backwards. SQLite querying a few hundred thousand rows with a decent index is fast — sub-millisecond fast. So is Postgres. The engine was almost never your bottleneck.

The bottleneck is distance, multiplied by how many times you cross it. A page that runs six sequential queries against a database 2,000 miles away pays that round trip six times before it renders anything. That’s where the “why is our dashboard slow” feeling comes from, and no amount of query optimization fixes it, because the queries aren’t slow — the phone line is long.

Edge databases attack the distance. Code runs near the user, read replicas put a copy of the data near the code, and the six round trips shrink toward local. For a read-heavy app — and most business apps are overwhelmingly read-heavy — that’s the whole ballgame.

Two honest caveats. Writes still go to a single primary, so a write from Sacramento pays the trip to wherever the primary lives. And a chatty query pattern is still a chatty query pattern; fixing the N+1 in your code will usually beat any infrastructure change you can buy.

Cost stops scaling with time and starts scaling with use

A managed Postgres instance bills for existence. The smallest production-grade instance at a traditional cloud provider, plus a standby for failover, plus backup storage, lands in the low hundreds per month before a single customer touches it. That’s the floor, and it doesn’t move whether you serve 100 requests a day or 100,000.

D1 bills on rows read, rows written, and gigabytes stored. There is no floor. An internal tool used by nine people at a contracting company costs pennies. A public app doing real traffic costs meaningfully more, but the curve starts at zero and bends gently.

For the client apps we ship, the whole stack — Pages, Workers, D1, R2, KV — typically runs $40–$300/month, and D1 is a small slice of that. The database line item stops being something anyone thinks about. (Cloudflare’s per-unit rates change; check their pricing page rather than trusting a number in a blog post, including this one.)

Operations mostly disappear — but application design doesn’t

No instance to patch, no version upgrade window, no connection pool exhaustion at 2 a.m., no “the database ran out of disk” page.

What remains: schema design, migrations, indexes, seed data, secrets management, and knowing what happens when a write fails. The edge removes infrastructure babysitting. It does not remove engineering. Anyone who tells you serverless means you stop thinking about the database is selling something.

Where D1 is genuinely the right answer

  • Content-and-forms sites with a dynamic layer. Marketing site, gated resources, quote requests, a small admin view. Overwhelmingly reads.
  • Internal business tools. Job tracking, inventory, scheduling, approvals — the spreadsheet replacements. Small data, modest write volume, high value.
  • Client portals. Login, view your projects, download documents, submit a request.
  • Analytics and event logging at moderate volume. Append rows, aggregate on a schedule.
  • AI workflow state. Conversation history, extraction results, job queues, audit logs for automated workflows. The data volume is small; the read pattern is hot.

Notice the shape: modest data size, read-dominant traffic, latency the user can feel.

Where it’s the wrong tool

Be blunt about this, because picking wrong is expensive later.

Workload Verdict
Read-heavy app, data under a few GB D1 — good fit
Constant concurrent writes (high-volume transactional system) Postgres
Datasets in the tens or hundreds of GB in one database Postgres or a data warehouse
Needs PostGIS, pgvector, or other Postgres extensions Postgres (or Vectorize for embeddings)
Long analytical queries over millions of rows A warehouse; don’t run BI on your app database
Team standardized on Rails/Django with a Postgres-shaped ORM Postgres, with Cloudflare in front
Large files, images, backups R2, not any database

The single-primary write model is the real ceiling. SQLite serializes writes; that’s a design choice, not a defect, and it’s why it’s so reliable. If your app’s defining characteristic is thousands of concurrent writers hitting the same table, you want a database built for that, and Cloudflare will happily sit in front of it.

Also worth saying plainly: if your current Postgres setup works and costs $60/month, migrating it to the edge is not a project with a payback case. Do it on new builds.

Portability, which is the question you should ask

Every platform decision should come with an exit. D1 exports to standard SQL. SQLite’s file format is documented to a degree almost nothing else in software matches, and the project has a stated commitment to support it into the 2050s. Moving to Postgres later is a schema-translation task — real work, but a Tuesday, not a crisis.

The stickier dependency in an edge stack is the Workers glue and routing around the database, not the data. That’s true of every platform’s serverless layer, and it’s the thing to weigh honestly before you commit.

How we actually decide

On a new custom app, the database question takes about twenty minutes and comes down to four answers:

  1. How big does the data get in three years? Under a few gigabytes per logical database, D1 stays comfortable.
  2. What’s the read-to-write ratio? Strongly read-heavy favors the edge. Write-saturated doesn’t.
  3. Does anything need a Postgres-only feature? Geospatial queries, vector search, exotic extensions — if yes, that decides it.
  4. Who maintains it after launch? Fewer moving parts means fewer things a small business has to keep alive.

Then it gets tested. Test-driven development is house policy here, and database code is where it earns its keep — migrations that run against a real schema, queries with assertions, and a suite that fails loudly when someone changes a column. You can see how we run projects on our process page, and what past builds looked like in our work.

You probably don’t need to care

If you own a business rather than write the code, here’s the whole article in four questions to ask whoever builds your app: Was the database chosen deliberately for this workload? Can we export the data? What’s the monthly run cost at our expected traffic? Who fixes it at 2 a.m.?

Good answers to those four matter more than which engine won. A well-designed app on the wrong database is still a good app. A badly designed one on the perfect database is still slow.

If you’re weighing an edge stack for a build in Rocklin, Roseville, Auburn, Lincoln, or anywhere else in the Sacramento region, we’re happy to talk through whether it fits — including telling you it doesn’t. We quote flat, we’re at 6770 Stanford Ranch Rd in Roseville, and a conversation costs nothing.

Related reading: The 2026 Cloudflare stack: Workers, D1, and the edge · Why we build on Cloudflare · Why your website should be boring and fast · Custom apps we build

FAQ

Frequently asked questions.

The questions clients ask most after reading this.

What is an edge database in plain terms?

A database that lives close to your code instead of in one distant data center. Traditional apps put the database in, say, Virginia, and every page load makes a round trip there. An edge database keeps the data on the same network your code runs on — often the same city as the visitor for reads. Less distance means less waiting, and no server sitting idle between requests.

What does 'SQLite at the edge' actually mean for D1?

D1 is real SQLite, the same embedded database inside every phone and browser, run as a managed service on Cloudflare's network. You write ordinary SQL — CREATE TABLE, SELECT, JOIN, indexes, transactions. What's different is the operations model: no server to size, no connection pool to tune, no idle cost. The SQL you know transfers almost unchanged.

How fast is D1 compared to a normal cloud database?

The gain isn't raw query speed — SQLite was always fast on small datasets. The gain is round trips. A page that runs six queries against a database 2,000 miles away pays that distance six times. On the edge, with read replication and code sitting next to the data, those round trips shrink dramatically. Fixing a chatty query pattern usually matters more than the database engine either way.

What does D1 cost to run for a typical small-business app?

For most business apps we ship, the database is a rounding error — the whole stack (Workers, D1, R2, KV, Pages) typically runs $40–$300/month, and D1 is a small slice of that. Cloudflare bills on rows read, rows written, and stored data rather than server hours, so a low-traffic internal tool costs close to nothing. Check Cloudflare's current pricing page for exact per-unit rates.

When is D1 the wrong choice?

Write-heavy systems with constant concurrent updates, datasets well beyond a few gigabytes per database, workloads that need Postgres extensions like PostGIS or pgvector, long analytical queries over millions of rows, and teams standardized on a Rails or Django stack that expects Postgres. In those cases we use Postgres and put Cloudflare in front of it instead.

Can I get my data out of D1 later?

Yes. D1 exports to standard SQL, and SQLite's file format is one of the best-documented, longest-lived formats in software. Moving to Postgres or MySQL is a schema-translation job, not a rescue mission. The stickier part of any edge stack is the routing and Workers glue around the database, not the data itself.

Do I need to care which database my app uses?

Mostly no. It's your builder's call, and the right answer depends on read/write shape and data size, not on preference. What you should care about is whether the choice was made deliberately, whether your data can be exported, what the monthly run cost is at your expected traffic, and who is on the hook when something breaks. Ask those four questions and let the engine be an implementation detail.

Who helps small businesses near Rocklin and Roseville, CA with edge databases and custom apps?

Grey Sky Media, a boutique software studio founded in Rocklin in 1999 with 187+ projects shipped. We build on Astro, React, and Cloudflare's edge — Workers, D1, R2, KV — with test-driven development as house policy and flat-bid pricing, no hourly. Custom apps typically run $40K–$150K+ and $40–$300/month to operate. Studio at 6770 Stanford Ranch Rd #1200, Roseville CA 95678. Call (916) 234-0040.

More development reading

Related from the lab.

All field notes

Can AI help?

What's the task your team does manually every day?

Tell us in plain words. We'll ask a couple of questions, then tell you honestly whether it's worth automating — no sales pitch.