‹ All demos
LiveDatabases · Built from scratch

QueryLite: a SQL database

A SQL database written from scratch — parser, B+ tree indexes, a query planner, joins and transactions — running live on 22,000 rows in your browser.

How it works

  1. 1A hand-written parser turns SQL into a syntax tree. Errors point to the exact spot: “Expected FROM near FORM”.
  2. 2Every index is a B+ tree. The planner picks an index lookup when a condition can use one — unless it would match most of the table, when reading every row is cheaper.
  3. 3Joins run as an index nested loop, a hash join or a plain nested loop, depending on what is indexed. The plan shown is the one that ran, with real row counts.
  4. 4BEGIN, COMMIT and ROLLBACK use an undo log, and indexes are kept in step. Your changes are saved in this browser.