UnionAll should be able to reserve the order property comming from its children #59869
Labels
sig/execution
SIG execution
sig/planner
SIG: Planner
type/enhancement
The issue or PR belongs to an enhancement.
Enhancement
suppose that we have table
and a SQL
select * from (select a from t union all select a from t) t order by a limit 1
.The best plan is that we keep the order property by reading index
idx
of table t and the union can also use the order property to perform a merge sort to output the data. In this way, we don't need any extra sort to sort the data can directly perform limit upon the union all.current TiDB lacks the functionality and will do a sort after the union all. no rewrite can achieve the best possible plan until the union all can do the merge sort.
The text was updated successfully, but these errors were encountered: