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)
Optimize query performance for LIMIT, LIMIT BY, and ORDER BY clauses when using distributed tables with GROUP BY on the sharding key.

Why it matters

This feature addresses inefficiencies in query execution plans involving distributed tables where GROUP 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 with GROUP 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.