
Query SQLite on GitHub Pages with sql.js-httpvfs
Originally published at recca0120.github.io I once had a 670 MB SQLite database and a simple requirement: put it on a static site so users could search it by keyword. Use a backend? The whole project was static — I didn't want to spin up a server just for this. Upload the raw DB and have the browser download it? Nobody is waiting for 670 MB. That's when I found sql.js-httpvfs , and the problem went away. It builds on sql.js , adding an HTTP Range Request-based virtual file system so the browser only fetches the SQLite pages a query actually needs. That same 670 MB database? A simple key lookup transfers roughly 1 KB. How it works: fetching only what you need SQLite stores data in fixed-size pages (4096 bytes by default). Every B-Tree node, every index entry, and every row maps to a specific page number. When you run an indexed query, SQLite only needs to read the pages along the B-Tree path — it never has to scan the whole table. sql.js-httpvfs exploits this by replacing the Emscripten
Continue reading on Dev.to
Opens in a new tab




