Expand description
WindowTopN optimizer rule for per-partition top-K window queries.
Detects queries of the form:
SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY pk ORDER BY val) as rn
FROM t
) WHERE rn <= K;And replaces the FilterExec โ BoundedWindowAggExec โ SortExec pipeline
with BoundedWindowAggExec โ PartitionedTopKExec(fetch=K), removing both
the FilterExec and SortExec.
See PartitionedTopKExec
for details on the replacement operator.
Structsยง
- Window
TopN - Physical optimizer rule that converts per-partition
ROW_NUMBERtop-K queries into a more efficient plan usingPartitionedTopKExec.