-- Shows where rows are growing and how effective aggregation currently is. SET time_zone = '+00:00'; SELECT table_name, table_rows, ROUND(data_length/1024/1024,1) AS data_mb, ROUND(index_length/1024/1024,1) AS index_mb, ROUND((data_length+index_length)/1024/1024,1) AS total_mb FROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length + index_length DESC; SELECT 'event_count_buckets' AS source, COUNT(*) AS rows_24h, COALESCE(SUM(cnt),0) AS represented_events_24h, ROUND(COALESCE(SUM(cnt),0) / NULLIF(COUNT(*),0), 1) AS events_per_row FROM event_count_buckets WHERE bucket_start >= UTC_TIMESTAMP() - INTERVAL 24 HOUR UNION ALL SELECT 'event_occurrences', COUNT(*), COALESCE(SUM(cnt),0), ROUND(COALESCE(SUM(cnt),0) / NULLIF(COUNT(*),0), 1) FROM event_occurrences WHERE bucket_start >= UTC_TIMESTAMP() - INTERVAL 24 HOUR; SELECT channel_name, event_id, COUNT(*) AS context_rows_24h, SUM(cnt) AS represented_events_24h, ROUND(SUM(cnt)/NULLIF(COUNT(*),0),1) AS events_per_row FROM event_occurrences WHERE bucket_start >= UTC_TIMESTAMP() - INTERVAL 24 HOUR GROUP BY channel_name, event_id ORDER BY context_rows_24h DESC LIMIT 50;