You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge?
When applying new orderings via with_reorder(), the current implementation discards all existing ordering information and replaces it with the new ordering. This is suboptimal because in many cases, parts of the existing ordering remain valid and could be preserved.
For example, if we have data ordered by [a ASC, b DESC] and apply a new ordering [a ASC], we currently lose the information that the data is also ordered by b DESC, even though this ordering is still valid and could be valuable for query optimization.
This overly conservative approach can lead to unnecessary sorting operations in query execution, impacting query performance.
Describe the solution you'd like
Enhance with_reorder() to preserve valid ordering information by:
Filtering out constant expressions from ordering considerations (they don't affect physical ordering)
Preserving valid suffixes from existing orderings when they're compatible with the new ordering
Considering expression equivalences when comparing orderings
For example:
When applying [a ASC] to existing [a ASC, b DESC], preserve b DESC
When columns a and b are equivalent and applying [b ASC] to existing [a ASC, c DESC], preserve c DESC
When column a is constant, applying [a ASC, b ASC] should only consider [b ASC]
Describe alternatives you've considered
Only preserve exact matching prefixes without considering equivalences
Additional context
This optimization is particularly important for complex queries with multiple ordering requirements and transformations, where maintaining ordering information can significantly reduce the number of required sort operations.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem or challenge?
When applying new orderings via
with_reorder()
, the current implementation discards all existing ordering information and replaces it with the new ordering. This is suboptimal because in many cases, parts of the existing ordering remain valid and could be preserved.For example, if we have data ordered by
[a ASC, b DESC]
and apply a new ordering[a ASC]
, we currently lose the information that the data is also ordered byb DESC
, even though this ordering is still valid and could be valuable for query optimization.This overly conservative approach can lead to unnecessary sorting operations in query execution, impacting query performance.
Describe the solution you'd like
Enhance
with_reorder()
to preserve valid ordering information by:For example:
[a ASC]
to existing[a ASC, b DESC]
, preserveb DESC
a
andb
are equivalent and applying[b ASC]
to existing[a ASC, c DESC]
, preservec DESC
a
is constant, applying[a ASC, b ASC]
should only consider[b ASC]
Describe alternatives you've considered
Only preserve exact matching prefixes without considering equivalences
Additional context
This optimization is particularly important for complex queries with multiple ordering requirements and transformations, where maintaining ordering information can significantly reduce the number of required sort operations.
The text was updated successfully, but these errors were encountered: