From 89f0856a04e9fa8713de953aeaa7916b9149902f Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 9 Apr 2026 03:54:12 +0400 Subject: [PATCH] fix: speed up rollups --- apps/api/src/jobs/rollup.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/api/src/jobs/rollup.ts b/apps/api/src/jobs/rollup.ts index 9df5794..d58fed0 100644 --- a/apps/api/src/jobs/rollup.ts +++ b/apps/api/src/jobs/rollup.ts @@ -105,7 +105,9 @@ export async function startRollupJob() { console.error("[rollup] force-run check failed:", e); } - // Periodic refreshes for the *current* bucket of each resolution. - setInterval(() => { rollupCurrent("hourly").catch((e) => console.warn("[rollup] hourly failed:", e)); }, 5 * 60 * 1000); - setInterval(() => { rollupCurrent("daily").catch((e) => console.warn("[rollup] daily failed:", e)); }, 30 * 60 * 1000); + // Periodic refreshes for the *current* bucket of each resolution. Each query + // is bounded by the current bucket only (date_trunc(...)) so it stays cheap + // even at high cadence. + setInterval(() => { rollupCurrent("hourly").catch((e) => console.warn("[rollup] hourly failed:", e)); }, 30 * 1000); // every 30s + setInterval(() => { rollupCurrent("daily").catch((e) => console.warn("[rollup] daily failed:", e)); }, 5 * 60 * 1000); // every 5min }