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 }