apache / apache/datafusion

Expand PartialSort usage in more queries to reduce memory usage

Open
#9,153 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

PartialSort proposed in https://github.com/apache/arrow-datafusion/pull/9125 can also be used on bounded input which will help reducing memory usage for the sorts when the input is already partially sorted (input plan ordering and plan required ordering has a common prefix)

### Describe the solution you'd like

We might need to consider incorporating `ExternalSorter` in `PartialSortExec` plan as it is used in `SortExec`. Then it should be completely safe to replace `SortExec` with `PartialSortExec` in `EnforceSorting` without checking for unboundedness of input.

### Describe alternatives you've considered

Implementing partial sort logic inside `SortExec` and making `SortExec` choose which sorting logic to run might be an option.

It can also be argued that it is easier to understand the intention when `PartialSortExec` and `SortExec` are kept as separate plans.

### Additional context

https://github.com/apache/arrow-datafusion/issues/7456

Contributor guide

Open the contributing guide

Research direction

Start by reading the PartialSort proposal in PR 9125 and compare PartialSortExec with SortExec, especially ExternalSorter and the EnforceSorting path. Review issue 7456 for context. Done means bounded inputs with partially matching orderings can use PartialSortExec safely without the current unboundedness check, while preserving sorting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-engineering, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.