mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
Add a covering partial index over (user_id, type, measured_at DESC) WHERE deleted_at IS NULL (migration 0183). The hot reads all filter deleted_at and order measured_at DESC, but the base index is ASC and excludes deleted_at, so every type not served by the two existing partial indexes pays a heap re-check of deleted_at over its partition. The covering partial removes the re-check for the DISTINCT-ON-latest, list and series reads. Cap the cold-fallback all-time aggregate in summaries-slice at a 15-year window. It sits far beyond any real history, so it never changes a real all-time count/min/max/mean; it exists only so a coverage-miss cold read can't trigger an unbounded full-partition scan.