Problem
DatabaseSizeLatestSql, the WPF viewer's FinOps "latest database sizes" read, spends almost all of its time planning. It has no collection_time bound, so the planner considers every retained database_size_stats chunk to find the newest snapshot.
Measured
From #4227's field comment: a production SQL Server store, 2026-09-25, the busiest server, read-only EXPLAIN (ANALYZE, BUFFERS). The read took 2.6 ms to execute and 148 ms to plan, with 80 buffers, over 71 database_size_stats chunks.
Until #4240, FinOps refreshed every 30 s, so this ran twice a minute per open tab. #4240 moves the tab to a refresh on activation, which cuts how often it runs. Each activation still pays the planning cost, and that cost grows with retention and with the chunk count.
Fix shape
- Bound the read by
collection_time so the planner can exclude old chunks, without changing the result. The newest snapshot must still come back for a server whose collection stopped days ago. One option: probe each server's newest collection_time first (a one-chunk read), then read that snapshot with the bound.
- Measure planning before and after on a seeded store with 30+ days of chunks.
- Check Lite: DuckDB has no chunks, so this is likely Darling only. Say so with the reason.
Related
Problem
DatabaseSizeLatestSql, the WPF viewer's FinOps "latest database sizes" read, spends almost all of its time planning. It has nocollection_timebound, so the planner considers every retaineddatabase_size_statschunk to find the newest snapshot.Measured
From #4227's field comment: a production SQL Server store, 2026-09-25, the busiest server, read-only
EXPLAIN (ANALYZE, BUFFERS). The read took 2.6 ms to execute and 148 ms to plan, with 80 buffers, over 71database_size_statschunks.Until #4240, FinOps refreshed every 30 s, so this ran twice a minute per open tab. #4240 moves the tab to a refresh on activation, which cuts how often it runs. Each activation still pays the planning cost, and that cost grows with retention and with the chunk count.
Fix shape
collection_timeso the planner can exclude old chunks, without changing the result. The newest snapshot must still come back for a server whose collection stopped days ago. One option: probe each server's newestcollection_timefirst (a one-chunk read), then read that snapshot with the bound.Related