
EngineeringTechnology
D1 Deep Dive: SQLite at the Edge for Production Workloads
What is D1?
D1 is Cloudflare's serverless SQL database based on SQLite. Think of it as SQLite with superpowers: edge replication, automatic backups, and HTTP-based access.

Why SQLite?
SQLite processes more SQL queries than all other database engines combined. It's used in every smartphone, every browser, and now β every edge location.
- Single-file database β no daemon, no config
- ACID compliant with WAL mode
- Read performance: millions of queries/second
- 1014 (10 trillion) SQLite databases in active use worldwide
Schema Management with Payload
Payload automatically manages your D1 schema through drizzle-orm. When you add a field to a collection, Payload generates the migration:
1// Payload auto-generates SQL migrations2// Run: npx payload migrate3ALTER TABLE posts ADD COLUMN "featured" integer DEFAULT false;4CREATE INDEX IF NOT EXISTS "posts_featured_idx" ON "posts" ("featured");Query Patterns
1// Local API β type-safe, no HTTP overhead2const featured = await payload.find({3 collection: 'posts',4 where: {5 featured: { equals: true },6 _status: { equals: 'published' },7 },8 sort: '-publishedAt',9 limit: 5,10 depth: 2,11})12 13// REST API equivalent:14// GET /api/posts?where[featured][equals]=true&sort=-publishedAtBackup & Recovery
D1 provides time-travel recovery β restore your database to any point within the last 30 days.
Comments
Related Posts

TechnologyEngineering
1 min
Real benchmarks, D1 architecture, and a production deploymenβ¦

Design
1 min
Spatial design, oklch() color systems, semantic motion, and β¦

Business
1 min
ROI analysis, migration strategy, and cost breakdown for entβ¦