
Storage Format
If you're working with Turso or need to understand how SQLite actually stores data on disk, this breaks down the file format internals. You get the page structure, B-tree organization, cell formats, overflow chains, and freelist management with actual byte offsets and diagrams. It points you to the relevant Rust files in Turso's codebase (btree.rs, pager.rs, sqlite3_ondisk.rs) and explains how table rows map to varints and serial types. Useful when you're debugging storage issues, optimizing page usage, or just curious why your database file is structured the way it is. The reference links to SQLite's official docs and Fly.io's internals writeup are solid next steps.
- skills.sh installs
- 1.3K
- GitHub stars
- 25.2K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add tursodatabase/turso --skill storage-format --agent claude-codeInstalls into .claude/skills of the current project.
Files
Storage Format Guide
Database File Structure
┌─────────────────────────────┐
│ Page 1: Header + Schema │ ← First 100 bytes = DB header
├─────────────────────────────┤
│ Page 2..N: B-tree pages │ ← Tables and indexes
│ Overflow pages │
│ Freelist pages │
└─────────────────────────────┘
Page size: power of 2, 512-65536 bytes. Default 4096.
Database Header (First 100 Bytes)
| Offset | Size | Field |
|---|---|---|
| 0 | 16 | Magic: "SQLite format 3\0" |
| 16 | 2 | Page size (big-endian) |
| 18 | 1 | Write format version (1=rollback, 2=WAL) |
| 19 | 1 | Read format version |
| 24 | 4 | Change counter |
| 28 | 4 | Database size in pages |
| 32 | 4 | First freelist trunk page |
| 36 | 4 | Total freelist pages |
| 40 | 4 | Schema cookie |
| 56 | 4 | Text encoding (1=UTF8, 2=UTF16LE, 3=UTF16BE) |
All multi-byte integers: big-endian.
Page Types
Sponsors
Details
- Repository
- github.com/tursodatabase/turso
- Categories
- Code Review & Quality, Databases
- First seen
- May 16, 2026