v.20.4Improvement
Optimize Queries with LIMIT and ORDER BY for GROUP BY Sharding Key
Optimize queries with LIMIT/LIMIT BY/ORDER BY for distributed with GROUP BY sharding_key #10373 (Azat Khuzhin)
Why it matters
This feature addresses inefficiencies in query execution plans involving distributed tables whereGROUP BY is applied on the sharding key alongside LIMIT, LIMIT BY, or ORDER BY. By optimizing such queries, it reduces unnecessary data processing and network load, thereby improving query latency and resource utilization.How to use it
Users benefit from this optimization automatically when running queries on distributed tables withGROUP BY clauses that include the sharding key, combined with LIMIT, LIMIT BY, or ORDER BY. No explicit user action is required to enable this optimization.