How we sped up Notion in the browser with WASM SQLite
Notion’s move to run SQLite in the browser via WebAssembly is seen as a major validation of client-side SQL databases, offering faster page navigation and offloading heavy query work to users’ machines. Commenters contrast this approach with the long-troubled IndexedDB and abandoned WebSQL standards, arguing that browser storage APIs are fragmented, underpowered, and often buggy, especially at scale or across multiple tabs. At the same time, many note that performance gains are undermined by broader UX and loading issues in modern web apps, and lament the lack of robust offline support despite powerful local databases now being available.
WASM SQLite in the Browser (Notion & Others)
- Notion uses WASM SQLite with OPFS as a local cache; others report similar production use with Kotlin/JS and SQLDelight.
- Reported benefits: powerful local querying (joins, full-text search), large local caches, and noticeable navigation speedups compared to server-only data fetches.
- Significant engineering cost: awkward OPFS tooling/debugging, concurrency pitfalls, single-worker constraints, non-idiomatic official JS bindings, and complex multi-tab coordination.
- Some describe WASM SQLite + OPFS as “incredibly powerful”; others call the stack “a nightmare” due to multi‑MB WASM downloads, corruption edge cases, and complex write coordination.
IndexedDB, LocalStorage, and WebSQL Debates
- IndexedDB is widely criticized: verbose “NoSQL-ish” API, per-row overhead, inconsistent and buggy implementations, hard debugging, sometimes blocking the main thread even via workers, and no strong persistence guarantees.
- LocalStorage: too small (≈10 MB), synchronous, contention issues, and unreliable with multiple tabs.
- WebSQL/SQLite-in-browser: some argue it was a missed opportunity and would be far better than the current IndexedDB ecosystem; others argue standardizing on SQLite would freeze an old version and massively expand attack surface.
- Several note that browsers already use SQLite internally but do not expose it, which is seen as a “missed chance” by some and a deliberate safety choice by others.
OPFS and File-System Concerns
- OPFS gives more disk and better perf but has tricky concurrency; a “multiple readers/writers” proposal is implemented in Chrome, welcomed by some but not widely adopted.
- Some wish browsers would expose a more “real” file system or align with WASI; others strongly oppose giving web pages direct file access for security reasons.
Performance, Local-First, and Cloud Costs
- Multiple commenters praise local SQLite (and DuckDB for OLAP) for being able to scan tens of MBs–GBs in milliseconds on SSDs.
- There’s debate over cloud IOPS pricing: some see local-offload as economically compelling; others argue million‑IOPS disk is overkill and real workloads are CPU/network bound.
Notion-Specific UX Concerns
- Despite the new cache, users still complain about slow loading, laggy tables (especially on mobile), lack of true offline mode, and growing UI bloat.