Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
tursodatabase avatar

Storage Format

  • 946 installs
  • 23.5k repo stars
  • Updated July 28, 2026
  • tursodatabase/turso

storage-format is a skill that explains how Turso and SQLite physically store data on disk—including B-trees, pages, cells, and freelists—for developers who debug performance, design schemas, or build custom database ext

About

storage-format is a Turso database skill documenting the SQLite 3 on-disk file layout used by tursodb. It maps the 100-byte database header, B-tree page structure, cell and overflow pages, and freelist mechanics, with default page size 4096 bytes and supported sizes from 512 to 65536 bytes as powers of two. Developers use storage-format when diagnosing slow queries, reasoning about index layout, estimating storage overhead, or extending Turso with format-aware tooling. The skill is reference depth for physical storage, not a migration or ORM tutorial.

  • Explains the complete SQLite database file structure including header, B-tree pages, overflow, and freelist
  • Details the first 100-byte database header with all field offsets, sizes, and meanings
  • Covers all five page types (interior/leaf index/table B-trees, overflow, freelist) and their binary flags
  • Describes B-tree variants: 64-bit rowid Table B-trees versus Index B-trees
  • Documents page size rules, big-endian encoding, and power-of-two constraints from 512 to 65536 bytes

Storage Format by the numbers

  • 946 all-time installs (skills.sh)
  • +47 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #90 of 923 Databases skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/tursodatabase/turso --skill storage-format

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs946
repo stars23.5k
Security audit3 / 3 scanners passed
Last updatedJuly 28, 2026
Repositorytursodatabase/turso

How does SQLite store data on disk?

Understand exactly how Turso and SQLite physically store data on disk when debugging performance, designing schemas, or building custom extensions.

Who is it for?

Backend developers debugging Turso or SQLite performance, schema design, or building format-aware database tooling.

Skip if: Developers who only need SQL query help or ORM setup without caring about physical page or B-tree internals.

When should I use this skill?

User asks about SQLite file format, B-trees, page size, Turso storage internals, or on-disk performance debugging.

What you get

Accurate mental model and reference for SQLite page layout, B-tree structure, header fields, and freelist behavior in Turso files.

  • storage layout reference
  • debugging guidance

By the numbers

  • SQLite database header is 100 bytes on page 1
  • Supported page sizes range 512–65536 bytes with 4096-byte default

Files

SKILL.mdMarkdownGitHub ↗

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)

OffsetSizeField
016Magic: "SQLite format 3\0"
162Page size (big-endian)
181Write format version (1=rollback, 2=WAL)
191Read format version
244Change counter
284Database size in pages
324First freelist trunk page
364Total freelist pages
404Schema cookie
564Text encoding (1=UTF8, 2=UTF16LE, 3=UTF16BE)

All multi-byte integers: big-endian.

Page Types

FlagTypePurpose
0x02Interior indexIndex B-tree internal node
0x05Interior tableTable B-tree internal node
0x0aLeaf indexIndex B-tree leaf
0x0dLeaf tableTable B-tree leaf
-OverflowPayload exceeding cell capacity
-FreelistUnused pages (trunk or leaf)

B-tree Structure

Two B-tree types:

  • Table B-tree: 64-bit rowid keys, stores row data
  • Index B-tree: Arbitrary keys (index columns + rowid)
Interior page:  [ptr0] key1 [ptr1] key2 [ptr2] ...
                   │         │         │
                   ▼         ▼         ▼
               child     child     child
               pages     pages     pages

Leaf page:     key1:data  key2:data  key3:data ...

Page 1 always root of sqlite_schema table.

Cell Format

Table Leaf Cell

[payload_size: varint] [rowid: varint] [payload] [overflow_ptr: u32?]

Table Interior Cell

[left_child_page: u32] [rowid: varint]

Index Cells

Similar but key is arbitrary (columns + rowid), not just rowid.

Record Format (Payload)

[header_size: varint] [type1: varint] [type2: varint] ... [data1] [data2] ...

Serial types:

TypeMeaning
0NULL
1-41/2/3/4 byte signed int
56 byte signed int
68 byte signed int
7IEEE 754 float
8Integer 0
9Integer 1
≥12 evenBLOB, length=(N-12)/2
≥13 oddText, length=(N-13)/2

Overflow Pages

When payload exceeds threshold, excess stored in overflow chain:

[next_page: u32] [data...]

Last page has next_page=0.

Freelist

Linked list of trunk pages, each containing leaf page numbers:

Trunk: [next_trunk: u32] [leaf_count: u32] [leaf_pages: u32...]

Turso Implementation

Key files:

  • core/storage/sqlite3_ondisk.rs - On-disk format, PageType enum
  • core/storage/btree.rs - B-tree operations (large file)
  • core/storage/pager.rs - Page management
  • core/storage/buffer_pool.rs - Page caching

Debugging Storage

# Integrity check
cargo run --bin tursodb test.db "PRAGMA integrity_check;"

# Page count
cargo run --bin tursodb test.db "PRAGMA page_count;"

# Freelist info
cargo run --bin tursodb test.db "PRAGMA freelist_count;"

References

Related skills

How it compares

Use storage-format for on-disk internals; use SQL or ORM skills for application-level queries without physical layout needs.

FAQ

What page sizes does storage-format document for SQLite?

storage-format states SQLite page sizes are powers of two from 512 to 65536 bytes, with 4096 bytes as the common default. Page 1 holds the 100-byte database header plus schema root B-tree data.

Is storage-format specific to Turso?

storage-format covers the SQLite file format used by tursodb, including B-trees, cells, overflow pages, and freelists. The same on-disk layout applies when debugging Turso-hosted SQLite databases.

Is Storage Format safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Databasesbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.