Running:
SELECT count(*) AS exact_count FROM hits;
We see:

With 30M Rows. This query takes 244 seconds. β³
Running this query for each hit badge was crashing the server. π
But with the hit_count table in place, it's now not a burning issue π₯ π₯
priority-2 because the aggregation isn't crashing the server anymore and we can fix this with time. π§βπ» π
Starting point: https://stackoverflow.com/questions/55018986/postgresql-select-count-query-takes-long-time
Running:
We see:

With
30M Rows. This query takes 244 seconds. β³Running this query for each
hitbadge was crashing the server. πBut with the
hit_counttable in place, it's now not a burning issue π₯ π₯priority-2because the aggregation isn't crashing the server anymore and we can fix this with time. π§βπ» πStarting point: https://stackoverflow.com/questions/55018986/postgresql-select-count-query-takes-long-time