Affects Version/s: None
Fix Version/s: 1.17.0
We're working on an optimization in Phoenix to optimize away an ORDER BY when it is known based on equality expressions in the WHERE clause that it is not necessary (
PHOENIX-2194). It'd be great if Calcite could do that as well.
Here's a example, given the following schema:
In the following queries, no sort is necessary:
There are also some edge cases where a function may be known to select a prefix of the column value where it's still ok to not sort:
But if another column is included in the ORDER BY after the prefixing, a sort would still be necessary: