SQLite Tags Benchmark: Comparing 5 Tagging Strategies

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Developers tagging data in SQLite now have measured evidence that indexed lookup tables beat JSON and LIKE approaches by wide margins.

Read this as

Simon Willison ran a test comparing five ways to store and search 'tags', labels attached to records, in SQLite, a popular free database. Using 100,000 rows and 100 possible tags, he found that traditional link tables and indexed lookup tables answered queries in under 1.5 milliseconds, while storing tags as raw JSON or searching text with pattern matching was far slower. Anyone building apps with tagged content can use these results directly.

This is practical engineering guidance, not product news: a developer benchmarking five SQLite tagging strategies on 100,000 rows found indexed approaches, materialized lookup tables on JSON and classic many-to-many tables, complete single-tag queries in under 1.5 milliseconds. Simpler JSON-based designs carry a steep performance penalty. Teams choosing a tagging schema can avoid a costly redesign by following these trade-offs between speed, storage and complexity.

A micro-benchmark (run via Claude Code) compared five SQLite tagging strategies on 100,000 rows, 100 tags, averaging 6.5 tags per row. Classic many-to-many tables and materialized lookup tables on JSON were fastest, handling single-tag queries in under 1.5 ms; FTS5 placed a close second. Full-table scans using LIKE performed better than expected, while JSON arrays with json_each() were much slower. Caveat: small synthetic scale and single-tag queries only.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

SQLite FTS5 Pyodide Claude Code Datasette

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading