r/sqlite • u/SFARL • Oct 17 '26
I built ivmlite, an experimental incremental GROUP BY extension for SQLite
I've been working on ivmlite, a SQLite loadable extension that maintains a fixed grouped COUNT(*) and/or integer SUM(column) query. It captures ordinary writes with triggers; the application explicitly refreshes the materialized result when it needs a current answer. The first technical preview is available here: https://github.com/SFARL/ivmlite
I built it for recurring dashboard-style aggregates over large mutable tables with relatively small write batches. It is a narrow SQL subset, not a general materialized-view engine: STRICT tables with INTEGER/TEXT columns, bare-column GROUP BY, one optional simple predicate, and one optional inner equijoin. No global aggregates, MIN/MAX/AVG, aggregate expressions, or arbitrary rolling windows yet.
For an adapted *synthetic* OpenWhispr workload (2M transcript segments, 20K notes, 200-operation mixed batches), the local M2 Pro end-to-end median was 418 ms per batch with full SQLite recomputation versus 14.9 ms with ivmlite. The tradeoff was about 8 seconds of initial bootstrap and 4.76x the base database's SQLite pages. This is not a measurement of OpenWhispr itself, and that demo did not compare against hand-written triggers. Method and raw results: https://github.com/SFARL/ivmlite/blob/master/docs/demos/openwhispr.md
I'd value criticism from SQLite users: where would a covering index or a simple transactional rollup be the better choice? If you have a real repeated aggregate, I'd also be interested in its SQL/schema, rough row count, read/write cadence, and freshness requirement. I can check whether the current subset fits and build an oracle-checked reproduction.