mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
The latest canonical reading per type ran as `DISTINCT ON (type)` over every live row of the account in five places (summaries slice warm and cold path, comprehensive aggregator warm and cold path, targets). With no skip scan in Postgres 16 that sorted the whole account to keep one row per type. `readLatestCanonical` drives the read from the type list instead: one index probe for each type's latest instant, then a closed one-day window ranked by the source ladder. The closed window also keeps the plan under `jit_above_cost`. The targets read reuses `readLatestEver` with a floor. The summaries slice was built inside three cache cells (the tile-strip route, the thick analytics body, the dashboard snapshot). It now has one cell, read through `readSummariesSlice`; composing callers read it fresh-only so a refresh after a write cannot cache the pre-write slice again, and the snapshot folds the water tile into a copy instead of the cached object.