Back to the journal

SQLite at the edge, without the guesswork.

A query-first checklist for thinking clearly about D1, indexes, and where latency really comes from.

Reference guide. This article draws on primary documentation and editorial recommendations; no production measurements are reported.

Begin with the query

Before choosing an architecture, write down the reads and writes your application actually needs. A small editorial site might list published posts, fetch one slug, and append a comment. Those operations tell you more than a generic database comparison.

Cloudflare D1 offers a managed serverless database with SQLite SQL semantics. That describes its interface; it does not tell you what your application’s end-to-end latency will be.

Inspect the plan

Use SQLite’s EXPLAIN QUERY PLAN to inspect index usage and scan strategy. Read it as a debugging aid: SQLite explicitly warns that its output format can change between releases. The example below assumes an articles table with slug, title, status, and published_at columns; adapt it to your own schema.

EXPLAIN QUERY PLAN
SELECT slug, title
FROM articles
WHERE status = 'published'
ORDER BY published_at DESC
LIMIT 20;

Measure the whole request

  • Use a representative dataset rather than an almost empty database.

  • Measure application response time separately from database query time.

  • Record client location, deployment configuration, cache state, and error rate.

  • Review indexes against both read paths and write costs.

Keep local correctness checks separate from remote performance observations. A fast local query cannot establish how a deployed request behaves.

Keep the first version legible

Choose explicit migrations, parameterized statements, and a documented recovery procedure. Before adding replication or caching, describe the consistency your readers need. This guide proposes a checklist; it contains no production performance measurements.

Cloudflare: D1 overview

SQLite: EXPLAIN QUERY PLAN

How this story was made

Prepared with AI assistance. Sources are linked in the story. This reference guide describes an approach; it does not report a production deployment.

The conversation

MODERATED, ALWAYS

A useful question, a different result, a missing detail. Start there.