Skip to content

Add SQLite Query Explainer tool#299

Merged
simonw merged 2 commits into
mainfrom
claude/sqlite-query-explainer-ab7dxo
Jul 18, 2026
Merged

Add SQLite Query Explainer tool#299
simonw merged 2 commits into
mainfrom
claude/sqlite-query-explainer-ab7dxo

Conversation

@simonw

@simonw simonw commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Build a tool that uses Pyodide to run sql queries against a SQLite database and also runs explain (and explain query plan) against them and annotates the explain output with really clear explanations of what everything means

Start by prototyping with Python to figure out the best ways to explain the different things that can happen in an explain

The page should come with a default database which is loaded if the user clicks “Load example database” - that one can have some large tables in since it can run loops to populate them. It should include several example queries for the user to pick which illustrate as many explain patterns as possible

OR the user can open their own SQLite database and run their own queries - if they open their own SQLite database it starts by showing them the schema of it using a query against sqlite_master

Runs SQL queries against a SQLite database via Pyodide (Python's sqlite3
in the browser) and annotates the output of both EXPLAIN QUERY PLAN and
EXPLAIN with plain-English descriptions of what SQLite is doing.

  • "Load example database" builds 170k+ rows across five tables (with
    indexes, a WITHOUT ROWID table and a view) using loops with a fixed
    random seed, plus 22 example queries chosen to illustrate as many
    query plan patterns as possible: full scans, rowid lookups, covering
    indexes, nested-loop joins, temp b-tree sorts, MULTI-INDEX OR,
    automatic indexes, materialized vs co-routine CTEs, recursive CTEs,
    window functions and more
  • Or open your own SQLite database file (copied into the browser
    sandbox, never modified) - it starts by running a query against
    sqlite_master to show the schema
  • EXPLAIN QUERY PLAN renders as an annotated tree with badges, and
    consecutive loops are labeled with their nested-loop join role
  • EXPLAIN bytecode instructions cross-reference each other: jump
    targets are clickable links, jump-target rows show which
    instructions jump to them, loop bodies get depth bars, and hovering
    a register or cursor highlights everywhere else it is used

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Vx3Jgd4JPLFsKLwT8BemnL

claude added 2 commits July 18, 2026 17:03
Runs SQL queries against a SQLite database via Pyodide (Python's sqlite3
in the browser) and annotates the output of both EXPLAIN QUERY PLAN and
EXPLAIN with plain-English descriptions of what SQLite is doing.

- "Load example database" builds 170k+ rows across five tables (with
  indexes, a WITHOUT ROWID table and a view) using loops with a fixed
  random seed, plus 22 example queries chosen to illustrate as many
  query plan patterns as possible: full scans, rowid lookups, covering
  indexes, nested-loop joins, temp b-tree sorts, MULTI-INDEX OR,
  automatic indexes, materialized vs co-routine CTEs, recursive CTEs,
  window functions and more
- Or open your own SQLite database file (copied into the browser
  sandbox, never modified) - it starts by running a query against
  sqlite_master to show the schema
- EXPLAIN QUERY PLAN renders as an annotated tree with badges, and
  consecutive loops are labeled with their nested-loop join role
- EXPLAIN bytecode instructions cross-reference each other: jump
  targets are clickable links, jump-target rows show which
  instructions jump to them, loop bodies get depth bars, and hovering
  a register or cursor highlights everywhere else it is used

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vx3Jgd4JPLFsKLwT8BemnL
Queries run against the example database are stored in the URL hash
(#sql=...). Opening a bookmarked URL automatically loads Pyodide,
rebuilds the example database and runs the query; changing the hash
(back/forward navigation or pasting a link) re-runs it in place.

Queries against a user-opened database file clear the hash instead,
since that file can't be restored from a URL. The example picker gains
a placeholder entry and deselects itself when the SQL in the editor no
longer matches the chosen example.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vx3Jgd4JPLFsKLwT8BemnL
@claude

claude Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@simonw

simonw commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@simonw
simonw merged commit b82441e into main Jul 18, 2026
1 of 4 checks passed
@simonw
simonw deleted the claude/sqlite-query-explainer-ab7dxo branch July 18, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants