Skip to content

fix(benchmarks): correct TPC-H benchmark SQL#21615

Merged
comphead merged 2 commits intoapache:mainfrom
kumarUjjawal:fix/incorrect_tpch_queries
Apr 15, 2026
Merged

fix(benchmarks): correct TPC-H benchmark SQL#21615
comphead merged 2 commits intoapache:mainfrom
kumarUjjawal:fix/incorrect_tpch_queries

Conversation

@kumarUjjawal
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

TPC-H query 11 was using a fixed 0.0001 threshold in the HAVING clause. Per the TPC-H spec, this value must be 0.0001 / SF.

This means the benchmark query is only correct for scale factor 1. For larger scale factors the filter becomes too
strict, and for smaller scale factors it becomes too loose.

There are also few benchmark queries using fixed end dates where the spec uses date + interval. Those are equivalent but using intervals matches the TPC-H query definitions more closely.

What changes are included in this PR?

  • Make TPC-H query 11 use scale-factor substitution.
  • Add scale factor support in the benchmark runner.
  • Infer scale factor from dataset paths like tpch_sf10.
  • Pass the scale factor from bench.sh.
  • Keep the old query-loading entry point working with the
    default scale factor of 1.
  • Update query 5, 6, 10, 12, and 14 to use interval-based
    date ranges.
  • Add regression tests for scale-factor substitution,
    scale-factor parsing, and invalid scale factors.

Are these changes tested?

Yes

Are there any user-facing changes?

TPC-H benchmark query 11 now returns correct results when the scale factor is not 1.

@kumarUjjawal
Copy link
Copy Markdown
Contributor Author

cc @Omega359

@Omega359
Copy link
Copy Markdown
Contributor

Thank you, this looks reasonable to me.

@comphead
Copy link
Copy Markdown
Contributor

run benchmark tpch

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4248112740-1267-dmb6r 6.12.55+ #1 SMP Sun Feb 1 08:59:41 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 fix/incorrect_tpch_queries (b232880) to 6db3899 (merge-base) diff using: tpch
Results will be posted here when complete


File an issue against this benchmark runner

@Dandandan
Copy link
Copy Markdown
Contributor

run benchmark tpch10

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4249605829-1273-pz4d7 6.12.55+ #1 SMP Sun Feb 1 08:59:41 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 fix/incorrect_tpch_queries (b232880) to 6db3899 (merge-base) diff using: tpch10
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 fix_incorrect_tpch_queries
--------------------
Benchmark tpch_sf10.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                HEAD ┃         fix_incorrect_tpch_queries ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1  │   371.68 / 377.77 ±7.18 / 391.56 ms │  386.96 / 389.77 ±2.31 / 392.92 ms │     no change │
│ QQuery 2  │   138.84 / 140.85 ±2.04 / 144.26 ms │  142.84 / 147.40 ±3.10 / 151.45 ms │     no change │
│ QQuery 3  │   301.42 / 306.17 ±3.86 / 310.39 ms │  303.36 / 316.46 ±7.93 / 327.15 ms │     no change │
│ QQuery 4  │   157.86 / 160.52 ±1.47 / 162.08 ms │  157.04 / 161.06 ±3.80 / 168.18 ms │     no change │
│ QQuery 5  │   437.03 / 441.92 ±4.41 / 449.41 ms │  442.33 / 450.78 ±5.49 / 458.95 ms │     no change │
│ QQuery 6  │   134.35 / 137.83 ±3.20 / 142.91 ms │  133.88 / 135.13 ±1.04 / 136.64 ms │     no change │
│ QQuery 7  │   565.14 / 580.64 ±8.76 / 589.92 ms │  568.20 / 574.77 ±5.98 / 585.58 ms │     no change │
│ QQuery 8  │   485.00 / 490.17 ±4.99 / 496.32 ms │  482.46 / 491.75 ±5.36 / 498.87 ms │     no change │
│ QQuery 9  │  685.40 / 700.85 ±11.48 / 716.52 ms │  754.49 / 756.25 ±1.25 / 757.75 ms │  1.08x slower │
│ QQuery 10 │   359.08 / 373.95 ±9.11 / 384.92 ms │  361.48 / 371.09 ±6.40 / 378.12 ms │     no change │
│ QQuery 11 │   113.63 / 118.22 ±4.45 / 124.86 ms │  111.12 / 116.93 ±5.13 / 124.03 ms │     no change │
│ QQuery 12 │   216.24 / 218.52 ±2.77 / 223.83 ms │  205.37 / 208.31 ±2.91 / 212.23 ms │     no change │
│ QQuery 13 │  327.29 / 344.05 ±13.16 / 362.68 ms │  317.54 / 325.72 ±6.51 / 334.84 ms │ +1.06x faster │
│ QQuery 14 │   186.03 / 187.78 ±1.67 / 190.55 ms │  185.09 / 187.42 ±1.68 / 189.13 ms │     no change │
│ QQuery 15 │   338.21 / 341.11 ±1.83 / 343.50 ms │  335.95 / 340.66 ±3.45 / 346.48 ms │     no change │
│ QQuery 16 │      86.70 / 88.61 ±1.04 / 89.61 ms │     84.72 / 87.02 ±1.55 / 88.88 ms │     no change │
│ QQuery 17 │  772.10 / 795.05 ±38.52 / 871.59 ms │  777.90 / 781.61 ±3.86 / 788.53 ms │     no change │
│ QQuery 18 │ 921.63 / 980.73 ±29.96 / 1001.64 ms │ 856.32 / 880.41 ±14.57 / 900.50 ms │ +1.11x faster │
│ QQuery 19 │   283.44 / 288.08 ±3.69 / 292.62 ms │  276.40 / 287.65 ±6.56 / 294.24 ms │     no change │
│ QQuery 20 │   329.71 / 335.29 ±4.51 / 339.96 ms │  349.71 / 357.44 ±9.31 / 375.19 ms │  1.07x slower │
│ QQuery 21 │   862.94 / 871.83 ±6.96 / 883.46 ms │ 870.66 / 914.81 ±37.40 / 969.33 ms │     no change │
│ QQuery 22 │      85.37 / 87.62 ±1.81 / 90.50 ms │     81.75 / 83.29 ±1.03 / 84.96 ms │     no change │
└───────────┴─────────────────────────────────────┴────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                         ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                         │ 8367.55ms │
│ Total Time (fix_incorrect_tpch_queries)   │ 8365.70ms │
│ Average Time (HEAD)                       │  380.34ms │
│ Average Time (fix_incorrect_tpch_queries) │  380.26ms │
│ Queries Faster                            │         2 │
│ Queries Slower                            │         2 │
│ Queries with No Change                    │        18 │
│ Queries with Failure                      │         0 │
└───────────────────────────────────────────┴───────────┘

Resource Usage

tpch10 — base (merge-base)

Metric Value
Wall time 42.3s
Peak memory 10.1 GiB
Avg memory 7.7 GiB
CPU user 441.2s
CPU sys 30.8s
Peak spill 0 B

tpch10 — branch

Metric Value
Wall time 42.2s
Peak memory 10.2 GiB
Avg memory 7.8 GiB
CPU user 440.4s
CPU sys 30.9s
Peak spill 0 B

File an issue against this benchmark runner

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 @kumarUjjawal it makes sense, thanks for bringing intervals back

@comphead comphead added this pull request to the merge queue Apr 15, 2026
Merged via the queue into apache:main with commit edf8ad3 Apr 15, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A few TPCH benchmark queries are incorrect causing issues when scale factor > 1

5 participants