Files
HealthLog/src/lib
Marc-André Bombeck 57795418fc perf(analytics): slim summaries SQL aggregation, 306k rows to 8
The v1.4.37.1 fire-and-forget hotfix unblocked the event loop
but live HAR still showed /api/analytics?slice=summaries at
~3.1 s per cache miss on a power-user account. Root cause: the
v1.4.35 implementation read EVERY DAY rollup bucket for the
user without a bucketStart window and composed count/min/max/
mean in JavaScript. On the live account that materialised as
a 306k-row transfer plus a JS loop.

Replace the unwindowed prisma.measurementRollup.findMany with
a per-type $queryRaw GROUP BY. Returns 8 rows
(one per type with count/min/max/mean already shaped server-
side) instead of 306k bucket rows. The downstream JS aggregation
is bypassed because the per-type aggregate arrives pre-composed.
Cache-miss budget on Marc-sized accounts: ~3.1 s expected to
drop into the < 100 ms range.

The narrow aggregate query continues to carry the windowed
avg7/avg30 and regression slope/r2 columns that the GROUP BY
cannot reconstruct. Response shape is unchanged.
2026-05-17 16:57:13 +02:00
..
2026-05-14 23:49:32 +02:00
2026-05-16 10:59:42 +02:00
2026-05-15 22:59:10 +02:00
2026-05-15 22:59:10 +02:00
2026-05-14 23:49:32 +02:00
2026-03-10 20:14:33 +01:00
2026-05-16 12:37:55 +02:00
2026-05-16 03:17:00 +02:00
2026-05-16 16:04:21 +02:00
2026-05-16 12:37:55 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-15 22:59:10 +02:00
2026-05-16 16:04:21 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-14 23:49:32 +02:00
2026-05-15 22:59:10 +02:00
2026-05-15 22:59:10 +02:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00
2026-05-15 22:59:10 +02:00
2026-05-14 23:49:32 +02:00
2026-03-10 20:14:33 +01:00
2026-03-10 20:14:33 +01:00