apache / apache/datafusion

`BoundedWindowAggExec` in `Linear` mode is slow for many-partitions

Open
#23,982 3 comments 0 reactions 1 assignee Claimed by @neilconway 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?

For every batch, `BoundedWindowAggExec` in `Linear` mode does two operations that are `O(n)` in the number of live partitions:

- `aggregate_evaluate_stateful` / `evaluate_stateful` iterate all of `PartitionBatches` and probe `PartitionWindowAggStates` for each partition, per window expression
- `update_partition_batch` calls `set_most_recent_row` on every buffered partition

This is pretty inefficient when the # of partitions significantly exceeds the batch size; most partitions won't receive a row in the current batch, so we shouldn't need to touch them.

### Describe the solution you'd like

_No response_

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.