-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize SortPreservingMergeExec for single-column merge #13642
Comments
take |
Hi @Dandandan does the |
As shown in my flamegraph profile, there are code paths that invoke |
Thanks for the flamegraph, indeed looks like it happens when dealing with working with
and |
It seems single column case is optimized here datafusion/datafusion/physical-plan/src/sorts/streaming_merge.rs Lines 168 to 180 in 8404cd0
|
EDIT: seems like the first SortExpr comes from I've found that the sort isn't actually planned as a single-column sort. The // SQL: row_number() over (partition by id6 order by v3 desc)
LexOrdering {
inner: [
PhysicalSortExpr {
expr: Column { name: "id6", index: 0 },
options: SortOptions { descending: false, nulls_first: false }
},
PhysicalSortExpr {
expr: Column { name: "v3", index: 1 },
options: SortOptions { descending: true, nulls_first: true }
}
]
} I'm not sure whether this behavior is expected or if the plan should have used a single-column sort optimization in this case. |
Hm I see the query has two I do think however there is opportunity for
|
Is your feature request related to a problem or challenge?
Describe the solution you'd like
Optimize the
SortPreservingMergeStream
for single column sorts, only converting to row-format when dealing with multi-column sorts.Describe alternatives you've considered
No response
Additional context
This should be beneficial for many queries involving
SortPreservingMerge
, such as #13586The text was updated successfully, but these errors were encountered: