Compiling Postgres to WASM with PGlite
summary
PG Lite compiles Postgres to WASM using Emscripten, embeds initdb, and replaces forking with single-user mode plus an unwound main loop that avoids syncify, yielding a 6–8x speedup over stack-unwinding. Output serializes to JSON, persistence uses the Emscripten VFS with IndexedDB (browser) and Node/Bun/Deno filesystems, and dynamic extension loading supports pgvector compiled (PostGIS is harder). Result is a <3MB embeddable Postgres with reactive live queries via PG_NOTIFY, real-time sync, and half‑million weekly npm downloads.
AI-written summary · about
chapters (14)
- 0:00Introduction to PGlight
- 1:38Understanding Web Assembly
- 2:56The Single User Mode Challenge
- 4:13Implementing the Wasm Port
- 6:39First Release and Limitations
- 7:50Optimizing Performance
- 9:36Bootstrapping with initdb
- 10:49Live Queries and Reactivity
- 12:05Example Application Showcase
- 13:07Extensions and Ecosystem
- 14:36Real World Adoptions
- 16:25PGlight Use Cases
- 18:03Future Goals for Libpglite
- 19:48Conclusion and Q&A
related talks
37mCustom data structures in managed Postgres using WASM
33mExtending your database server's abilities
16mAll the Postgres Things
24mThe Upsidedown Stack: React on the Server and Postgres in the Browser
56mLightning Talks
31mUsing Databases to pull your applications weight
34mPostgres 10, Performance, and You
43mWhy Postgres
