Skip to content

fix: Avoid unnecessary input repartitioning with ScalarSubqueryExec#21986

Merged
Dandandan merged 2 commits intoapache:mainfrom
neilconway:neilc/fix-subquery-repartition
May 2, 2026
Merged

fix: Avoid unnecessary input repartitioning with ScalarSubqueryExec#21986
Dandandan merged 2 commits intoapache:mainfrom
neilconway:neilc/fix-subquery-repartition

Conversation

@neilconway
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

ScalarSubqueryExec marked its main input (the parent query of the subquery) as benefitting from partitioning, but that was incorrect: ScalarSubqueryExec is just a passthrough node, so it doesn't benefit from input partitioning itself. This bug resulted in inserting unnecessary RepartitionExec nodes underneath ScalarSubqueryExec, notably in TPC-H Q22.

What changes are included in this PR?

  • Fix input-partitioning behavior for ScalarSubqueryExec
  • Add SLT test to confirm this behavior
  • Update expected plan for TPC-H Q22

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes, some query plans will change (and improve).

@neilconway neilconway changed the title fix: Avoid spurious repartitioning with ScalarSubqueryExec fix: Avoid spurious repartitioning with ScalarSubqueryExec May 2, 2026
@neilconway neilconway changed the title fix: Avoid spurious repartitioning with ScalarSubqueryExec fix: Avoid unnecessary input repartitioning with ScalarSubqueryExec May 2, 2026
@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels May 2, 2026
@comphead
Copy link
Copy Markdown
Contributor

comphead commented May 2, 2026

run benchmark tpch tpcds

Copy link
Copy Markdown
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @neilconway, waiting for benches, but the PR makes a lot of sense, the extra repartition is waste of cycles.

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4364275604-1979-d5phb 6.12.68+ #1 SMP Wed Apr 1 02:23:28 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing neilc/fix-subquery-repartition (a59ee8d) to ba038e9 (merge-base) diff using: tpch
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4364275604-1980-tnlrr 6.12.68+ #1 SMP Wed Apr 1 02:23:28 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing neilc/fix-subquery-repartition (a59ee8d) to ba038e9 (merge-base) diff using: tpcds
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

Comparing HEAD and neilc_fix-subquery-repartition
--------------------
Benchmark tpch_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query     ┃                           HEAD ┃ neilc_fix-subquery-repartition ┃    Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 1  │ 40.26 / 41.10 ±0.98 / 42.77 ms │ 39.82 / 41.57 ±1.30 / 42.97 ms │ no change │
│ QQuery 2  │ 20.94 / 21.24 ±0.27 / 21.63 ms │ 20.90 / 21.16 ±0.14 / 21.28 ms │ no change │
│ QQuery 3  │ 36.71 / 37.63 ±0.74 / 38.94 ms │ 36.05 / 38.22 ±1.27 / 39.69 ms │ no change │
│ QQuery 4  │ 18.46 / 18.93 ±0.52 / 19.92 ms │ 18.48 / 19.07 ±0.50 / 19.94 ms │ no change │
│ QQuery 5  │ 43.66 / 44.98 ±0.97 / 46.15 ms │ 43.62 / 45.79 ±1.11 / 46.73 ms │ no change │
│ QQuery 6  │ 17.07 / 17.41 ±0.20 / 17.67 ms │ 17.38 / 17.54 ±0.12 / 17.66 ms │ no change │
│ QQuery 7  │ 49.79 / 51.54 ±1.42 / 53.82 ms │ 50.03 / 52.11 ±1.53 / 54.50 ms │ no change │
│ QQuery 8  │ 47.12 / 47.20 ±0.06 / 47.28 ms │ 46.70 / 47.01 ±0.20 / 47.30 ms │ no change │
│ QQuery 9  │ 51.79 / 52.93 ±0.86 / 54.40 ms │ 52.18 / 53.22 ±1.21 / 55.56 ms │ no change │
│ QQuery 10 │ 65.48 / 66.34 ±0.98 / 68.21 ms │ 65.34 / 66.04 ±0.78 / 67.55 ms │ no change │
│ QQuery 11 │ 14.31 / 14.56 ±0.16 / 14.74 ms │ 13.94 / 14.04 ±0.10 / 14.19 ms │ no change │
│ QQuery 12 │ 26.33 / 26.98 ±0.33 / 27.22 ms │ 26.32 / 27.02 ±0.95 / 28.90 ms │ no change │
│ QQuery 13 │ 35.51 / 36.37 ±0.73 / 37.22 ms │ 35.29 / 35.97 ±0.58 / 36.89 ms │ no change │
│ QQuery 14 │ 26.97 / 27.11 ±0.11 / 27.27 ms │ 26.86 / 27.21 ±0.36 / 27.91 ms │ no change │
│ QQuery 15 │ 33.35 / 33.75 ±0.68 / 35.11 ms │ 33.26 / 33.85 ±0.89 / 35.59 ms │ no change │
│ QQuery 16 │ 15.48 / 15.56 ±0.06 / 15.63 ms │ 15.34 / 15.43 ±0.06 / 15.51 ms │ no change │
│ QQuery 17 │ 76.28 / 78.48 ±1.39 / 79.84 ms │ 76.84 / 77.53 ±0.44 / 78.20 ms │ no change │
│ QQuery 18 │ 68.56 / 69.89 ±0.82 / 70.89 ms │ 70.06 / 70.76 ±0.94 / 72.59 ms │ no change │
│ QQuery 19 │ 37.81 / 38.12 ±0.19 / 38.38 ms │ 37.60 / 37.82 ±0.29 / 38.36 ms │ no change │
│ QQuery 20 │ 39.34 / 39.65 ±0.24 / 40.08 ms │ 38.93 / 39.27 ±0.20 / 39.55 ms │ no change │
│ QQuery 21 │ 61.54 / 62.22 ±0.70 / 63.38 ms │ 59.86 / 60.85 ±1.13 / 62.99 ms │ no change │
│ QQuery 22 │ 23.79 / 24.19 ±0.25 / 24.50 ms │ 23.80 / 24.12 ±0.23 / 24.44 ms │ no change │
└───────────┴────────────────────────────────┴────────────────────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Benchmark Summary                             ┃          ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Total Time (HEAD)                             │ 866.18ms │
│ Total Time (neilc_fix-subquery-repartition)   │ 865.62ms │
│ Average Time (HEAD)                           │  39.37ms │
│ Average Time (neilc_fix-subquery-repartition) │  39.35ms │
│ Queries Faster                                │        0 │
│ Queries Slower                                │        0 │
│ Queries with No Change                        │       22 │
│ Queries with Failure                          │        0 │
└───────────────────────────────────────────────┴──────────┘

Resource Usage

tpch — base (merge-base)

Metric Value
Wall time 5.0s
Peak memory 5.4 GiB
Avg memory 5.0 GiB
CPU user 32.3s
CPU sys 2.4s
Peak spill 0 B

tpch — branch

Metric Value
Wall time 5.0s
Peak memory 5.6 GiB
Avg memory 5.0 GiB
CPU user 32.2s
CPU sys 2.3s
Peak spill 0 B

File an issue against this benchmark runner

@neilconway
Copy link
Copy Markdown
Contributor Author

It's a little odd we don't see any benchmark changes as a result of this PR ... the new plans are clearly better, so I think it's fine to land, but I'm mildly skeptical of these benchmark results.

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

Comparing HEAD and neilc_fix-subquery-repartition
--------------------
Benchmark tpcds_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                     HEAD ┃           neilc_fix-subquery-repartition ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1  │              7.13 / 7.76 ±0.84 / 9.42 ms │              7.06 / 7.46 ±0.76 / 8.98 ms │     no change │
│ QQuery 2  │        146.98 / 148.00 ±0.54 / 148.46 ms │        144.06 / 144.63 ±0.40 / 145.17 ms │     no change │
│ QQuery 3  │        114.11 / 115.88 ±1.74 / 119.18 ms │        111.61 / 112.45 ±0.59 / 113.38 ms │     no change │
│ QQuery 4  │    1341.27 / 1371.37 ±21.57 / 1399.37 ms │     1223.61 / 1235.57 ±9.20 / 1250.22 ms │ +1.11x faster │
│ QQuery 5  │        174.37 / 176.22 ±1.27 / 177.97 ms │        171.73 / 173.82 ±1.38 / 176.01 ms │     no change │
│ QQuery 6  │        128.99 / 132.90 ±3.15 / 137.55 ms │        128.20 / 129.14 ±0.51 / 129.72 ms │     no change │
│ QQuery 7  │        315.55 / 319.61 ±2.36 / 322.73 ms │        315.68 / 316.31 ±0.54 / 317.26 ms │     no change │
│ QQuery 8  │        113.17 / 113.93 ±0.79 / 115.45 ms │        111.85 / 113.40 ±1.15 / 114.87 ms │     no change │
│ QQuery 9  │         97.01 / 100.14 ±2.19 / 102.08 ms │          95.42 / 98.45 ±2.64 / 101.69 ms │     no change │
│ QQuery 10 │        102.83 / 103.26 ±0.29 / 103.68 ms │        100.30 / 101.87 ±1.59 / 104.74 ms │     no change │
│ QQuery 11 │       843.45 / 869.34 ±15.71 / 890.48 ms │        833.47 / 839.92 ±7.89 / 855.02 ms │     no change │
│ QQuery 12 │           43.25 / 43.55 ±0.25 / 43.98 ms │           42.40 / 42.85 ±0.57 / 43.95 ms │     no change │
│ QQuery 13 │        387.09 / 390.33 ±2.22 / 393.00 ms │        386.14 / 388.56 ±2.01 / 392.25 ms │     no change │
│ QQuery 14 │     1030.48 / 1035.28 ±2.44 / 1037.22 ms │     1024.98 / 1032.17 ±4.79 / 1038.89 ms │     no change │
│ QQuery 15 │           14.40 / 14.68 ±0.34 / 15.31 ms │           14.23 / 14.56 ±0.30 / 15.08 ms │     no change │
│ QQuery 16 │              7.35 / 7.50 ±0.15 / 7.79 ms │              7.39 / 7.47 ±0.09 / 7.64 ms │     no change │
│ QQuery 17 │        202.57 / 203.67 ±1.78 / 207.21 ms │        199.73 / 201.07 ±1.07 / 202.47 ms │     no change │
│ QQuery 18 │        123.09 / 124.12 ±0.89 / 125.74 ms │        121.51 / 123.37 ±1.21 / 125.31 ms │     no change │
│ QQuery 19 │        152.45 / 154.21 ±1.94 / 157.83 ms │        151.09 / 152.66 ±1.10 / 153.92 ms │     no change │
│ QQuery 20 │           12.83 / 13.28 ±0.32 / 13.70 ms │           12.61 / 13.07 ±0.45 / 13.92 ms │     no change │
│ QQuery 21 │           19.14 / 19.40 ±0.24 / 19.82 ms │           18.82 / 19.12 ±0.22 / 19.49 ms │     no change │
│ QQuery 22 │        472.55 / 475.82 ±2.52 / 478.92 ms │        467.02 / 470.36 ±3.42 / 476.86 ms │     no change │
│ QQuery 23 │     1009.83 / 1013.03 ±2.86 / 1017.90 ms │     1003.65 / 1009.03 ±4.69 / 1014.86 ms │     no change │
│ QQuery 24 │        630.12 / 632.75 ±2.07 / 635.12 ms │        624.37 / 629.95 ±3.36 / 634.69 ms │     no change │
│ QQuery 25 │        305.46 / 306.73 ±1.13 / 308.71 ms │        300.94 / 305.88 ±3.56 / 311.09 ms │     no change │
│ QQuery 26 │           76.34 / 76.63 ±0.30 / 77.20 ms │           75.01 / 75.26 ±0.31 / 75.86 ms │     no change │
│ QQuery 27 │              7.06 / 7.17 ±0.11 / 7.37 ms │              6.91 / 7.01 ±0.14 / 7.28 ms │     no change │
│ QQuery 28 │        146.78 / 148.44 ±1.27 / 150.15 ms │        147.14 / 149.20 ±1.97 / 152.74 ms │     no change │
│ QQuery 29 │        246.15 / 249.16 ±5.53 / 260.21 ms │        242.60 / 244.25 ±1.36 / 246.41 ms │     no change │
│ QQuery 30 │           41.53 / 41.85 ±0.34 / 42.48 ms │           41.02 / 41.37 ±0.39 / 42.13 ms │     no change │
│ QQuery 31 │        163.41 / 165.45 ±1.83 / 168.33 ms │        164.14 / 165.72 ±2.33 / 170.33 ms │     no change │
│ QQuery 32 │           13.17 / 13.49 ±0.24 / 13.87 ms │           13.14 / 13.32 ±0.19 / 13.67 ms │     no change │
│ QQuery 33 │        138.08 / 140.03 ±2.92 / 145.81 ms │        136.74 / 138.78 ±2.51 / 143.72 ms │     no change │
│ QQuery 34 │              6.91 / 7.09 ±0.22 / 7.50 ms │              6.97 / 7.14 ±0.26 / 7.65 ms │     no change │
│ QQuery 35 │        101.04 / 103.42 ±2.99 / 109.23 ms │          99.19 / 99.83 ±0.76 / 101.24 ms │     no change │
│ QQuery 36 │              6.78 / 6.99 ±0.14 / 7.18 ms │              6.82 / 7.01 ±0.23 / 7.41 ms │     no change │
│ QQuery 37 │              8.36 / 8.56 ±0.13 / 8.78 ms │              8.25 / 8.48 ±0.20 / 8.77 ms │     no change │
│ QQuery 38 │           86.49 / 87.13 ±0.37 / 87.63 ms │           84.37 / 86.52 ±2.06 / 90.38 ms │     no change │
│ QQuery 39 │        116.07 / 120.65 ±6.09 / 132.35 ms │        114.40 / 117.97 ±4.45 / 126.66 ms │     no change │
│ QQuery 40 │           95.36 / 97.32 ±1.87 / 99.98 ms │           92.35 / 94.61 ±1.47 / 95.98 ms │     no change │
│ QQuery 41 │           14.84 / 14.94 ±0.14 / 15.21 ms │           14.33 / 14.52 ±0.24 / 14.99 ms │     no change │
│ QQuery 42 │        106.86 / 109.40 ±2.58 / 113.74 ms │        105.74 / 106.97 ±1.87 / 110.68 ms │     no change │
│ QQuery 43 │              5.81 / 5.93 ±0.14 / 6.17 ms │              5.72 / 6.48 ±1.26 / 8.99 ms │  1.09x slower │
│ QQuery 44 │           10.75 / 10.95 ±0.12 / 11.12 ms │           10.40 / 10.66 ±0.15 / 10.86 ms │     no change │
│ QQuery 45 │           44.33 / 44.87 ±0.30 / 45.17 ms │           44.11 / 44.61 ±0.26 / 44.84 ms │     no change │
│ QQuery 46 │              8.54 / 8.70 ±0.18 / 9.05 ms │              8.37 / 8.51 ±0.18 / 8.85 ms │     no change │
│ QQuery 47 │        665.94 / 683.29 ±9.99 / 692.43 ms │        669.24 / 673.96 ±3.09 / 677.46 ms │     no change │
│ QQuery 48 │        274.89 / 279.39 ±4.47 / 287.38 ms │        272.57 / 278.11 ±4.98 / 284.48 ms │     no change │
│ QQuery 49 │        243.64 / 246.38 ±2.36 / 250.68 ms │        245.78 / 246.46 ±0.41 / 246.88 ms │     no change │
│ QQuery 50 │        182.90 / 186.07 ±2.42 / 190.20 ms │        183.52 / 187.45 ±3.81 / 193.96 ms │     no change │
│ QQuery 51 │        169.48 / 170.91 ±1.28 / 173.16 ms │        171.79 / 173.07 ±1.20 / 175.08 ms │     no change │
│ QQuery 52 │        106.91 / 107.38 ±0.33 / 107.86 ms │        107.18 / 107.80 ±0.54 / 108.71 ms │     no change │
│ QQuery 53 │        101.85 / 103.57 ±2.64 / 108.83 ms │        102.08 / 104.77 ±3.74 / 112.12 ms │     no change │
│ QQuery 54 │        144.45 / 146.12 ±1.07 / 147.76 ms │        144.15 / 146.26 ±1.54 / 148.05 ms │     no change │
│ QQuery 55 │        105.66 / 106.09 ±0.41 / 106.77 ms │        106.67 / 107.09 ±0.42 / 107.85 ms │     no change │
│ QQuery 56 │        138.17 / 139.58 ±1.94 / 143.30 ms │        138.55 / 139.66 ±0.74 / 140.73 ms │     no change │
│ QQuery 57 │        162.87 / 165.49 ±1.82 / 168.31 ms │        164.76 / 168.70 ±3.03 / 173.99 ms │     no change │
│ QQuery 58 │        243.01 / 244.30 ±1.11 / 245.53 ms │        240.06 / 242.28 ±1.62 / 244.40 ms │     no change │
│ QQuery 59 │        192.41 / 196.47 ±2.52 / 199.96 ms │        192.14 / 195.16 ±1.78 / 196.93 ms │     no change │
│ QQuery 60 │        139.41 / 142.01 ±2.24 / 145.54 ms │        138.68 / 139.51 ±0.70 / 140.47 ms │     no change │
│ QQuery 61 │           13.56 / 13.70 ±0.15 / 14.00 ms │           13.64 / 14.78 ±2.01 / 18.78 ms │  1.08x slower │
│ QQuery 62 │        848.77 / 854.17 ±4.68 / 860.28 ms │        841.28 / 851.29 ±6.53 / 859.09 ms │     no change │
│ QQuery 63 │        101.26 / 102.79 ±1.45 / 105.40 ms │        101.91 / 103.99 ±2.22 / 107.55 ms │     no change │
│ QQuery 64 │        619.44 / 626.91 ±5.48 / 633.24 ms │        620.18 / 624.49 ±4.06 / 630.47 ms │     no change │
│ QQuery 65 │        240.01 / 245.16 ±5.48 / 254.57 ms │        239.84 / 242.35 ±1.94 / 244.94 ms │     no change │
│ QQuery 66 │        214.61 / 222.19 ±7.31 / 235.40 ms │        214.72 / 221.21 ±6.57 / 233.68 ms │     no change │
│ QQuery 67 │        284.24 / 291.12 ±7.64 / 305.55 ms │        288.29 / 294.24 ±5.77 / 304.70 ms │     no change │
│ QQuery 68 │              8.65 / 8.95 ±0.24 / 9.24 ms │              8.65 / 8.85 ±0.26 / 9.35 ms │     no change │
│ QQuery 69 │          97.36 / 99.45 ±2.42 / 104.10 ms │          96.18 / 98.57 ±2.91 / 104.24 ms │     no change │
│ QQuery 70 │        308.79 / 314.83 ±5.60 / 324.27 ms │        312.66 / 323.94 ±7.79 / 334.00 ms │     no change │
│ QQuery 71 │        131.44 / 134.55 ±2.78 / 138.93 ms │        132.00 / 134.65 ±2.46 / 138.52 ms │     no change │
│ QQuery 72 │        531.37 / 539.62 ±5.59 / 547.57 ms │        526.00 / 537.50 ±6.30 / 544.73 ms │     no change │
│ QQuery 73 │              6.62 / 6.79 ±0.19 / 7.17 ms │              6.66 / 6.81 ±0.22 / 7.25 ms │     no change │
│ QQuery 74 │        523.51 / 538.83 ±9.87 / 553.86 ms │        521.13 / 527.37 ±6.48 / 538.50 ms │     no change │
│ QQuery 75 │        265.37 / 267.94 ±2.33 / 272.18 ms │        264.70 / 266.37 ±1.51 / 268.51 ms │     no change │
│ QQuery 76 │        129.19 / 129.77 ±0.52 / 130.40 ms │        128.70 / 130.12 ±1.04 / 131.81 ms │     no change │
│ QQuery 77 │        186.66 / 188.50 ±2.00 / 192.32 ms │        186.35 / 187.86 ±2.32 / 192.48 ms │     no change │
│ QQuery 78 │        305.45 / 307.99 ±2.03 / 310.24 ms │        302.92 / 305.97 ±2.43 / 309.67 ms │     no change │
│ QQuery 79 │        226.57 / 229.07 ±2.81 / 234.19 ms │        226.77 / 229.67 ±3.17 / 235.51 ms │     no change │
│ QQuery 80 │        299.49 / 301.98 ±1.70 / 304.72 ms │        295.59 / 299.73 ±2.21 / 301.99 ms │     no change │
│ QQuery 81 │           25.81 / 26.15 ±0.29 / 26.66 ms │           25.35 / 25.55 ±0.19 / 25.89 ms │     no change │
│ QQuery 82 │           38.62 / 39.28 ±0.46 / 39.83 ms │           38.48 / 38.74 ±0.46 / 39.67 ms │     no change │
│ QQuery 83 │           34.73 / 35.02 ±0.23 / 35.34 ms │           34.55 / 36.23 ±2.56 / 41.33 ms │     no change │
│ QQuery 84 │           45.78 / 45.93 ±0.16 / 46.21 ms │           45.86 / 46.39 ±0.43 / 47.09 ms │     no change │
│ QQuery 85 │        141.07 / 142.84 ±2.43 / 147.64 ms │        139.72 / 140.00 ±0.16 / 140.19 ms │     no change │
│ QQuery 86 │           37.10 / 37.47 ±0.24 / 37.84 ms │           36.52 / 37.86 ±1.70 / 41.05 ms │     no change │
│ QQuery 87 │              3.59 / 3.67 ±0.13 / 3.93 ms │              3.57 / 3.64 ±0.10 / 3.84 ms │     no change │
│ QQuery 88 │         98.32 / 102.16 ±5.74 / 113.59 ms │         99.85 / 100.31 ±0.50 / 101.24 ms │     no change │
│ QQuery 89 │        116.66 / 117.84 ±0.83 / 118.88 ms │        115.88 / 118.47 ±3.47 / 125.25 ms │     no change │
│ QQuery 90 │           22.40 / 22.96 ±0.48 / 23.79 ms │           22.14 / 22.48 ±0.23 / 22.83 ms │     no change │
│ QQuery 91 │           59.13 / 59.39 ±0.26 / 59.90 ms │           57.53 / 58.15 ±0.58 / 59.14 ms │     no change │
│ QQuery 92 │           56.22 / 56.77 ±0.36 / 57.26 ms │           55.21 / 55.81 ±0.57 / 56.66 ms │     no change │
│ QQuery 93 │        158.21 / 161.87 ±2.35 / 165.63 ms │        158.73 / 160.62 ±2.26 / 165.07 ms │     no change │
│ QQuery 94 │           60.79 / 61.09 ±0.26 / 61.41 ms │           60.17 / 61.20 ±1.44 / 63.99 ms │     no change │
│ QQuery 95 │        112.22 / 112.59 ±0.35 / 113.06 ms │        110.17 / 110.80 ±0.43 / 111.23 ms │     no change │
│ QQuery 96 │           69.07 / 69.25 ±0.22 / 69.52 ms │           67.21 / 69.22 ±1.36 / 71.01 ms │     no change │
│ QQuery 97 │        113.32 / 113.92 ±0.65 / 115.10 ms │        112.06 / 113.40 ±1.11 / 115.33 ms │     no change │
│ QQuery 98 │        149.30 / 150.87 ±0.94 / 151.95 ms │        148.70 / 149.72 ±0.99 / 151.43 ms │     no change │
│ QQuery 99 │ 10665.53 / 10718.27 ±35.15 / 10757.60 ms │ 10695.41 / 10776.70 ±82.48 / 10922.87 ms │     no change │
└───────────┴──────────────────────────────────────────┴──────────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                             ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                             │ 29779.68ms │
│ Total Time (neilc_fix-subquery-repartition)   │ 29576.69ms │
│ Average Time (HEAD)                           │   300.80ms │
│ Average Time (neilc_fix-subquery-repartition) │   298.75ms │
│ Queries Faster                                │          1 │
│ Queries Slower                                │          2 │
│ Queries with No Change                        │         96 │
│ Queries with Failure                          │          0 │
└───────────────────────────────────────────────┴────────────┘

Resource Usage

tpcds — base (merge-base)

Metric Value
Wall time 150.0s
Peak memory 6.3 GiB
Avg memory 5.7 GiB
CPU user 235.9s
CPU sys 7.2s
Peak spill 0 B

tpcds — branch

Metric Value
Wall time 150.0s
Peak memory 6.4 GiB
Avg memory 5.7 GiB
CPU user 234.3s
CPU sys 7.3s
Peak spill 0 B

File an issue against this benchmark runner

@Dandandan
Copy link
Copy Markdown
Contributor

It's a little odd we don't see any benchmark changes as a result of this PR ... the new plans are clearly better, so I think it's fine to land, but I'm mildly skeptical of these benchmark results.

I think it's quite obvious there is no difference: the output is a single row, so there is nothing to repartition (cost is negligible).

@Dandandan Dandandan added this pull request to the merge queue May 2, 2026
Merged via the queue into apache:main with commit 8010857 May 2, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary RepartitionExec + SortPreservingMergeExec on single-partition sorted output

4 participants