mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-06 17:03:32 +02:00
e22514882f
The GROUP BY type and GROUP BY drop_reason sub-queries in get_packet_stats (and get_packet_type_stats) filter by a time window but let the planner pick idx_packets_type / idx_packets_transmitted to get grouping for free. It then heap-checks the timestamp filter across the entire table, turning a bounded window into a full scan: on a 1.5M-row packets table the 24h stats load spent ~4.8s (type) + ~2.3s (drop_reason) instead of ~0.1s each. Pin these to idx_packets_timestamp with INDEXED BY so they range-scan the window (~50k rows) and group via a small temp b-tree. Verified on the live DB: 4.80s -> 0.10s and 2.32s -> 0.10s. Unlike a covering index this adds no write-path cost on the packet-insert hot path.