Skip to content

feat: Create dynamic filters in SortMergeJoin#21267

Draft
stuhood wants to merge 5 commits intoapache:mainfrom
paradedb:stuhood.smj-dynamic-filter-creation
Draft

feat: Create dynamic filters in SortMergeJoin#21267
stuhood wants to merge 5 commits intoapache:mainfrom
paradedb:stuhood.smj-dynamic-filter-creation

Conversation

@stuhood
Copy link
Copy Markdown
Contributor

@stuhood stuhood commented Mar 31, 2026

Which issue does this PR close?

Rationale for this change

This change fixes #20443, and adds support for generating dynamic filters for the left and right sides of a SortMergeJoin, in order to allow for range-based pruning of both sides of the join. Some consumers of the dynamic filter may even be able to seek/skip ahead on their inputs.

What changes are included in this PR?

To allow SortMergeJoin to actually propagate dynamic filters down to scans and get things working end to end, it was necessary to fix the handle_child_pushdown_result implementations of a variety of nodes which were failing to clone and update themselves.

Are these changes tested?

Yes.

Are there any user-facing changes?

Explain will now show dynamic filters for SortMergeJoin, and for the scans that they consume.

@github-actions github-actions bot added the core Core DataFusion crate label Mar 31, 2026
@stuhood
Copy link
Copy Markdown
Contributor Author

stuhood commented Mar 31, 2026

Supersedes #20455.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Mar 31, 2026
@stuhood stuhood force-pushed the stuhood.smj-dynamic-filter-creation branch 2 times, most recently from ff61597 to d7dcdd5 Compare March 31, 2026 05:29
@stuhood stuhood marked this pull request as draft March 31, 2026 05:49
@stuhood stuhood force-pushed the stuhood.smj-dynamic-filter-creation branch from d7dcdd5 to 155f789 Compare March 31, 2026 15:06
@Dandandan
Copy link
Copy Markdown
Contributor

run benchmark tpch tpcds

env:
   PREFER_HASH_JOIN: false

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4168260905-641-j6htv 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 stuhood.smj-dynamic-filter-creation (155f789) to ccaf802 (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-c4168260905-642-t9w6j 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 stuhood.smj-dynamic-filter-creation (155f789) to ccaf802 (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 stuhood.smj-dynamic-filter-creation
--------------------
Benchmark tpch_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query     ┃                              HEAD ┃ stuhood.smj-dynamic-filter-creation ┃    Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 1  │    45.24 / 45.94 ±1.02 / 47.94 ms │      45.10 / 45.82 ±0.79 / 47.33 ms │ no change │
│ QQuery 2  │    62.30 / 62.70 ±0.33 / 63.29 ms │      64.12 / 64.77 ±0.67 / 65.97 ms │ no change │
│ QQuery 3  │    65.80 / 68.04 ±1.62 / 70.81 ms │      67.30 / 69.42 ±1.38 / 71.64 ms │ no change │
│ QQuery 4  │    49.71 / 50.23 ±0.49 / 51.04 ms │      48.98 / 50.20 ±0.79 / 51.14 ms │ no change │
│ QQuery 5  │ 104.19 / 108.51 ±2.61 / 111.40 ms │   110.09 / 111.50 ±1.59 / 114.29 ms │ no change │
│ QQuery 6  │    17.14 / 17.42 ±0.31 / 18.00 ms │      17.24 / 17.83 ±0.69 / 19.16 ms │ no change │
│ QQuery 7  │ 133.78 / 139.68 ±4.06 / 145.86 ms │   133.69 / 135.14 ±1.07 / 136.48 ms │ no change │
│ QQuery 8  │ 124.05 / 128.64 ±2.47 / 131.24 ms │   130.57 / 134.49 ±2.93 / 138.52 ms │ no change │
│ QQuery 9  │ 176.31 / 181.43 ±4.78 / 189.10 ms │   178.07 / 181.78 ±3.98 / 188.91 ms │ no change │
│ QQuery 10 │    85.60 / 87.71 ±1.86 / 90.39 ms │      87.70 / 88.33 ±0.60 / 89.16 ms │ no change │
│ QQuery 11 │    45.85 / 46.64 ±0.85 / 48.25 ms │      45.81 / 46.33 ±0.31 / 46.69 ms │ no change │
│ QQuery 12 │    37.66 / 38.72 ±0.61 / 39.54 ms │      38.01 / 39.31 ±0.75 / 40.34 ms │ no change │
│ QQuery 13 │    49.37 / 50.34 ±0.97 / 51.89 ms │      49.05 / 50.92 ±1.55 / 53.67 ms │ no change │
│ QQuery 14 │    29.16 / 29.45 ±0.36 / 30.15 ms │      29.43 / 29.80 ±0.24 / 30.09 ms │ no change │
│ QQuery 15 │    30.02 / 31.00 ±0.53 / 31.57 ms │      30.56 / 30.93 ±0.21 / 31.20 ms │ no change │
│ QQuery 16 │    21.59 / 22.18 ±0.45 / 22.97 ms │      21.76 / 22.18 ±0.32 / 22.65 ms │ no change │
│ QQuery 17 │ 117.37 / 121.05 ±2.63 / 123.98 ms │   117.44 / 121.00 ±2.43 / 123.49 ms │ no change │
│ QQuery 18 │ 146.26 / 148.03 ±1.14 / 149.72 ms │   147.66 / 149.84 ±1.86 / 152.46 ms │ no change │
│ QQuery 19 │    39.13 / 40.21 ±0.79 / 41.36 ms │      39.61 / 40.22 ±0.71 / 41.29 ms │ no change │
│ QQuery 20 │    57.61 / 60.29 ±1.83 / 61.80 ms │      57.94 / 60.49 ±1.34 / 61.56 ms │ no change │
│ QQuery 21 │ 270.08 / 274.39 ±2.81 / 277.53 ms │   266.98 / 270.57 ±2.89 / 274.82 ms │ no change │
│ QQuery 22 │    37.79 / 38.22 ±0.36 / 38.68 ms │      37.15 / 38.66 ±1.02 / 39.78 ms │ no change │
└───────────┴───────────────────────────────────┴─────────────────────────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                                  ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                                  │ 1790.82ms │
│ Total Time (stuhood.smj-dynamic-filter-creation)   │ 1799.52ms │
│ Average Time (HEAD)                                │   81.40ms │
│ Average Time (stuhood.smj-dynamic-filter-creation) │   81.80ms │
│ 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 9.3s
Peak memory 4.8 GiB
Avg memory 4.0 GiB
CPU user 73.8s
CPU sys 4.5s
Disk read 0 B
Disk write 140.0 KiB

tpch — branch

Metric Value
Wall time 9.2s
Peak memory 4.7 GiB
Avg memory 3.9 GiB
CPU user 74.3s
CPU sys 4.5s
Disk read 0 B
Disk write 72.0 KiB

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 stuhood.smj-dynamic-filter-creation
--------------------
Benchmark tpcds_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Query     ┃                                   HEAD ┃    stuhood.smj-dynamic-filter-creation ┃         Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ QQuery 1  │         52.30 / 52.86 ±0.77 / 54.35 ms │         29.86 / 30.72 ±0.69 / 31.91 ms │  +1.72x faster │
│ QQuery 2  │      146.72 / 147.55 ±0.59 / 148.41 ms │      148.30 / 148.99 ±0.60 / 150.08 ms │      no change │
│ QQuery 3  │      167.63 / 170.83 ±2.57 / 175.17 ms │      171.67 / 173.94 ±1.42 / 175.80 ms │      no change │
│ QQuery 4  │  1669.59 / 1749.08 ±43.27 / 1798.33 ms │  1684.94 / 1743.79 ±33.36 / 1780.29 ms │      no change │
│ QQuery 5  │      276.39 / 288.08 ±7.60 / 300.18 ms │      285.69 / 290.85 ±5.03 / 300.45 ms │      no change │
│ QQuery 6  │      245.14 / 247.05 ±2.05 / 250.57 ms │      244.27 / 246.85 ±1.91 / 249.38 ms │      no change │
│ QQuery 7  │      385.35 / 392.04 ±5.60 / 399.55 ms │      393.30 / 395.54 ±1.68 / 397.58 ms │      no change │
│ QQuery 8  │      189.51 / 191.63 ±2.11 / 195.06 ms │      183.98 / 191.84 ±4.79 / 198.75 ms │      no change │
│ QQuery 9  │      102.51 / 109.43 ±4.76 / 116.03 ms │      102.14 / 106.07 ±3.41 / 110.93 ms │      no change │
│ QQuery 10 │      256.32 / 258.92 ±2.09 / 262.20 ms │      257.86 / 262.72 ±3.26 / 266.57 ms │      no change │
│ QQuery 11 │      867.22 / 880.59 ±9.92 / 894.43 ms │     865.49 / 884.39 ±10.02 / 894.22 ms │      no change │
│ QQuery 12 │         53.30 / 54.20 ±0.60 / 54.85 ms │         55.60 / 56.17 ±0.78 / 57.70 ms │      no change │
│ QQuery 13 │      402.13 / 404.82 ±1.93 / 406.97 ms │      403.70 / 405.61 ±1.83 / 408.94 ms │      no change │
│ QQuery 14 │  2100.81 / 2123.33 ±20.56 / 2161.67 ms │   2137.00 / 2144.23 ±5.79 / 2150.69 ms │      no change │
│ QQuery 15 │         92.24 / 94.52 ±1.77 / 96.39 ms │         94.12 / 95.35 ±1.13 / 97.18 ms │      no change │
│ QQuery 16 │      159.49 / 160.59 ±0.95 / 162.22 ms │      161.00 / 164.12 ±1.96 / 166.83 ms │      no change │
│ QQuery 17 │      378.81 / 385.12 ±5.15 / 391.61 ms │      382.49 / 388.50 ±3.64 / 393.26 ms │      no change │
│ QQuery 18 │      292.96 / 297.38 ±3.38 / 301.61 ms │      290.14 / 302.41 ±6.41 / 307.18 ms │      no change │
│ QQuery 19 │      241.22 / 246.65 ±3.42 / 251.28 ms │      240.88 / 246.87 ±4.43 / 252.24 ms │      no change │
│ QQuery 20 │         90.57 / 92.42 ±1.45 / 94.79 ms │         92.70 / 94.03 ±1.51 / 96.85 ms │      no change │
│ QQuery 21 │      857.71 / 862.36 ±2.94 / 865.60 ms │      844.21 / 859.13 ±9.53 / 870.05 ms │      no change │
│ QQuery 22 │      400.27 / 415.16 ±8.13 / 425.08 ms │      404.59 / 411.25 ±6.11 / 420.39 ms │      no change │
│ QQuery 23 │  1145.00 / 1160.85 ±11.42 / 1177.24 ms │  1145.09 / 1176.14 ±25.03 / 1206.52 ms │      no change │
│ QQuery 24 │      905.73 / 918.29 ±7.32 / 927.96 ms │      872.92 / 877.24 ±3.23 / 881.07 ms │      no change │
│ QQuery 25 │      444.80 / 446.63 ±1.19 / 447.71 ms │      437.66 / 441.71 ±2.21 / 443.88 ms │      no change │
│ QQuery 26 │      205.37 / 211.81 ±4.76 / 218.80 ms │      206.06 / 210.09 ±2.73 / 213.72 ms │      no change │
│ QQuery 27 │      386.41 / 389.97 ±2.77 / 394.66 ms │      375.16 / 382.78 ±5.30 / 389.69 ms │      no change │
│ QQuery 28 │      150.57 / 151.40 ±0.60 / 152.39 ms │      150.29 / 152.08 ±1.33 / 154.37 ms │      no change │
│ QQuery 29 │      381.41 / 385.57 ±3.99 / 392.12 ms │      376.58 / 381.68 ±2.82 / 384.14 ms │      no change │
│ QQuery 30 │         54.89 / 56.24 ±1.10 / 57.47 ms │         57.90 / 58.56 ±0.62 / 59.49 ms │      no change │
│ QQuery 31 │      648.63 / 657.42 ±4.82 / 663.04 ms │      653.80 / 657.28 ±4.38 / 665.86 ms │      no change │
│ QQuery 32 │      148.70 / 149.87 ±0.83 / 150.86 ms │      149.57 / 150.46 ±1.03 / 152.38 ms │      no change │
│ QQuery 33 │      216.20 / 223.33 ±3.79 / 226.55 ms │      219.48 / 222.30 ±2.01 / 225.03 ms │      no change │
│ QQuery 34 │      190.39 / 194.13 ±3.15 / 199.60 ms │      187.65 / 188.48 ±0.90 / 190.12 ms │      no change │
│ QQuery 35 │      246.71 / 248.31 ±1.60 / 251.34 ms │      248.66 / 250.87 ±1.42 / 252.67 ms │      no change │
│ QQuery 36 │      281.40 / 283.28 ±1.66 / 285.42 ms │      284.38 / 286.47 ±2.23 / 289.59 ms │      no change │
│ QQuery 37 │      287.33 / 292.20 ±3.31 / 296.96 ms │         10.96 / 12.28 ±1.81 / 15.75 ms │ +23.80x faster │
│ QQuery 38 │      200.37 / 202.60 ±2.12 / 206.57 ms │      202.99 / 204.71 ±1.53 / 207.40 ms │      no change │
│ QQuery 39 │   3963.92 / 3971.78 ±7.67 / 3984.45 ms │  3938.72 / 3979.32 ±22.21 / 3997.13 ms │      no change │
│ QQuery 40 │      172.88 / 178.32 ±5.00 / 184.38 ms │      172.99 / 175.49 ±3.49 / 182.38 ms │      no change │
│ QQuery 41 │         14.75 / 16.15 ±1.04 / 17.37 ms │         14.66 / 15.37 ±0.96 / 17.25 ms │      no change │
│ QQuery 42 │      170.95 / 172.68 ±1.49 / 174.49 ms │      170.45 / 173.15 ±1.74 / 175.65 ms │      no change │
│ QQuery 43 │      151.22 / 154.10 ±2.50 / 157.47 ms │      156.29 / 161.02 ±3.57 / 166.18 ms │      no change │
│ QQuery 44 │         13.34 / 14.68 ±0.87 / 15.60 ms │         11.03 / 12.91 ±1.89 / 16.35 ms │  +1.14x faster │
│ QQuery 45 │         69.36 / 70.59 ±1.00 / 71.71 ms │         68.61 / 70.40 ±2.22 / 74.67 ms │      no change │
│ QQuery 46 │      354.69 / 359.38 ±2.66 / 362.34 ms │      344.95 / 349.47 ±3.66 / 355.19 ms │      no change │
│ QQuery 47 │      798.32 / 804.81 ±7.63 / 819.42 ms │      797.05 / 804.50 ±6.06 / 812.81 ms │      no change │
│ QQuery 48 │      289.70 / 293.37 ±2.19 / 295.61 ms │      290.12 / 293.16 ±2.33 / 296.62 ms │      no change │
│ QQuery 49 │      264.82 / 266.42 ±1.08 / 267.75 ms │      265.41 / 270.01 ±4.91 / 278.67 ms │      no change │
│ QQuery 50 │      230.03 / 234.23 ±3.36 / 238.44 ms │      228.74 / 230.81 ±1.96 / 234.06 ms │      no change │
│ QQuery 51 │      235.96 / 239.67 ±3.66 / 246.64 ms │      236.95 / 238.24 ±1.36 / 240.12 ms │      no change │
│ QQuery 52 │      170.18 / 173.06 ±1.93 / 175.39 ms │      171.05 / 173.25 ±1.67 / 175.80 ms │      no change │
│ QQuery 53 │      175.78 / 180.14 ±2.59 / 182.56 ms │      177.36 / 179.79 ±2.17 / 182.34 ms │      no change │
│ QQuery 54 │      267.43 / 271.11 ±2.63 / 274.82 ms │      270.85 / 277.97 ±5.32 / 284.38 ms │      no change │
│ QQuery 55 │      169.67 / 173.29 ±4.47 / 182.04 ms │      173.20 / 175.25 ±1.54 / 177.30 ms │      no change │
│ QQuery 56 │      216.26 / 223.21 ±3.90 / 226.93 ms │      223.08 / 225.90 ±1.95 / 229.04 ms │      no change │
│ QQuery 57 │      373.94 / 379.73 ±3.77 / 385.31 ms │      376.59 / 381.52 ±3.29 / 385.70 ms │      no change │
│ QQuery 58 │      413.34 / 417.38 ±3.81 / 423.45 ms │      405.88 / 416.41 ±6.66 / 425.05 ms │      no change │
│ QQuery 59 │      304.83 / 308.81 ±3.15 / 313.68 ms │      305.25 / 309.22 ±2.52 / 312.60 ms │      no change │
│ QQuery 60 │      215.35 / 221.04 ±3.16 / 224.55 ms │      222.29 / 225.10 ±3.08 / 230.62 ms │      no change │
│ QQuery 61 │      288.23 / 291.01 ±3.91 / 298.73 ms │      281.14 / 283.87 ±1.75 / 286.11 ms │      no change │
│ QQuery 62 │         86.22 / 87.65 ±1.23 / 89.38 ms │         86.29 / 86.93 ±0.40 / 87.41 ms │      no change │
│ QQuery 63 │      176.33 / 179.47 ±3.03 / 183.44 ms │      181.00 / 183.81 ±1.74 / 185.30 ms │      no change │
│ QQuery 64 │  1508.37 / 1526.06 ±12.22 / 1544.55 ms │   1530.30 / 1537.32 ±4.81 / 1542.69 ms │      no change │
│ QQuery 65 │      346.99 / 352.81 ±3.72 / 356.86 ms │      344.33 / 354.42 ±7.75 / 364.17 ms │      no change │
│ QQuery 66 │     296.41 / 312.35 ±11.30 / 328.03 ms │      302.15 / 311.15 ±7.42 / 319.37 ms │      no change │
│ QQuery 67 │      278.73 / 284.00 ±4.29 / 290.61 ms │      279.25 / 281.76 ±1.28 / 282.69 ms │      no change │
│ QQuery 68 │      414.47 / 421.74 ±4.87 / 427.57 ms │      409.10 / 411.40 ±1.89 / 414.80 ms │      no change │
│ QQuery 69 │      254.54 / 259.08 ±4.43 / 265.29 ms │      253.63 / 256.70 ±2.79 / 260.12 ms │      no change │
│ QQuery 70 │      452.21 / 459.33 ±3.83 / 462.87 ms │      454.12 / 459.87 ±4.25 / 466.82 ms │      no change │
│ QQuery 71 │      214.94 / 218.48 ±4.48 / 226.84 ms │      218.91 / 221.71 ±2.53 / 226.38 ms │      no change │
│ QQuery 72 │ 8619.56 / 9101.83 ±277.75 / 9421.56 ms │ 8621.28 / 9094.63 ±240.55 / 9284.71 ms │      no change │
│ QQuery 73 │     189.07 / 204.12 ±21.49 / 246.76 ms │      185.65 / 189.01 ±3.17 / 193.93 ms │  +1.08x faster │
│ QQuery 74 │      618.09 / 620.74 ±2.29 / 624.34 ms │      609.13 / 618.68 ±6.02 / 626.22 ms │      no change │
│ QQuery 75 │      532.86 / 547.75 ±8.77 / 557.23 ms │      535.74 / 543.84 ±5.83 / 553.89 ms │      no change │
│ QQuery 76 │      138.86 / 140.84 ±1.87 / 144.01 ms │      136.87 / 138.29 ±1.98 / 142.19 ms │      no change │
│ QQuery 77 │      286.62 / 288.84 ±1.50 / 290.22 ms │      281.23 / 284.46 ±3.20 / 289.54 ms │      no change │
│ QQuery 78 │      592.26 / 604.65 ±8.91 / 619.39 ms │     579.50 / 591.67 ±10.81 / 611.48 ms │      no change │
│ QQuery 79 │      360.15 / 364.32 ±2.53 / 367.26 ms │      349.13 / 352.61 ±2.50 / 355.19 ms │      no change │
│ QQuery 80 │      475.17 / 490.82 ±9.00 / 499.56 ms │      459.98 / 468.38 ±5.21 / 476.29 ms │      no change │
│ QQuery 81 │         59.80 / 63.34 ±3.42 / 67.56 ms │         62.14 / 67.43 ±4.90 / 75.16 ms │   1.06x slower │
│ QQuery 82 │      335.42 / 341.60 ±5.14 / 350.78 ms │      333.41 / 337.35 ±2.82 / 342.02 ms │      no change │
│ QQuery 83 │         69.31 / 71.76 ±2.15 / 74.98 ms │         68.38 / 70.15 ±1.71 / 72.60 ms │      no change │
│ QQuery 84 │         70.76 / 71.45 ±0.97 / 73.32 ms │         71.67 / 72.77 ±0.89 / 74.00 ms │      no change │
│ QQuery 85 │      183.55 / 189.02 ±4.64 / 196.45 ms │      183.80 / 188.31 ±2.62 / 191.88 ms │      no change │
│ QQuery 86 │         46.57 / 47.36 ±0.67 / 48.16 ms │         47.40 / 49.69 ±1.17 / 50.47 ms │      no change │
│ QQuery 87 │      204.21 / 205.93 ±1.42 / 208.43 ms │      206.06 / 207.45 ±1.80 / 210.91 ms │      no change │
│ QQuery 88 │      317.47 / 323.80 ±5.87 / 334.86 ms │      321.75 / 329.78 ±4.19 / 333.88 ms │      no change │
│ QQuery 89 │      182.43 / 188.63 ±5.82 / 198.75 ms │      180.72 / 186.77 ±4.08 / 192.74 ms │      no change │
│ QQuery 90 │         42.68 / 43.78 ±1.03 / 45.63 ms │         43.26 / 44.27 ±1.13 / 46.48 ms │      no change │
│ QQuery 91 │         72.08 / 73.66 ±1.27 / 75.90 ms │         73.94 / 76.62 ±2.18 / 80.30 ms │      no change │
│ QQuery 92 │         86.00 / 86.56 ±0.39 / 87.08 ms │         89.56 / 90.86 ±1.21 / 92.97 ms │      no change │
│ QQuery 93 │      394.60 / 397.14 ±1.46 / 399.10 ms │      399.36 / 404.66 ±4.51 / 411.35 ms │      no change │
│ QQuery 94 │        96.35 / 98.30 ±1.54 / 100.10 ms │        97.18 / 98.68 ±1.11 / 100.22 ms │      no change │
│ QQuery 95 │      178.04 / 179.93 ±1.94 / 183.22 ms │      179.47 / 182.55 ±2.83 / 187.79 ms │      no change │
│ QQuery 96 │      135.38 / 136.88 ±1.50 / 139.17 ms │      134.64 / 137.12 ±1.51 / 139.39 ms │      no change │
│ QQuery 97 │      209.73 / 211.05 ±1.69 / 214.31 ms │      209.72 / 212.26 ±2.42 / 216.60 ms │      no change │
│ QQuery 98 │      196.75 / 199.51 ±3.00 / 203.79 ms │      197.16 / 201.28 ±2.98 / 205.35 ms │      no change │
│ QQuery 99 │      217.78 / 220.83 ±1.87 / 223.67 ms │      221.42 / 224.24 ±2.74 / 228.23 ms │      no change │
└───────────┴────────────────────────────────────────┴────────────────────────────────────────┴────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                                  ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                                  │ 44626.87ms │
│ Total Time (stuhood.smj-dynamic-filter-creation)   │ 44287.52ms │
│ Average Time (HEAD)                                │   450.78ms │
│ Average Time (stuhood.smj-dynamic-filter-creation) │   447.35ms │
│ Queries Faster                                     │          4 │
│ Queries Slower                                     │          1 │
│ Queries with No Change                             │         94 │
│ Queries with Failure                               │          0 │
└────────────────────────────────────────────────────┴────────────┘

Resource Usage

tpcds — base (merge-base)

Metric Value
Wall time 223.5s
Peak memory 27.8 GiB
Avg memory 6.3 GiB
CPU user 909.8s
CPU sys 92.9s
Disk read 0 B
Disk write 638.2 MiB

tpcds — branch

Metric Value
Wall time 221.8s
Peak memory 27.6 GiB
Avg memory 6.1 GiB
CPU user 905.2s
CPU sys 92.7s
Disk read 0 B
Disk write 152.0 KiB

File an issue against this benchmark runner

@Dandandan
Copy link
Copy Markdown
Contributor

│ QQuery 37 │ 287.33 / 292.20 ±3.31 / 296.96 ms │ 10.96 / 12.28 ±1.81 / 15.75 ms │ +23.80x faster │

🚀🚀🚀

Copy link
Copy Markdown
Contributor

@adriangb adriangb left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. Can we split out the fixes for the other nodes into it's own PR that we can fast track (and maybe discuss any API improvements in)?

Then we can look at the SPM in more detail.

Comment on lines +658 to +665
if !matches!(phase, FilterPushdownPhase::Pre) {
let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
let mut new_self = self.clone();
new_self.input = updated_child;
result.updated_node = Some(Arc::new(new_self) as _);
}
return Ok(result);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch! This is definitely a footgun. Any thoughts on how we can make the API less error prone? It would also be nice to put this into its own PR so we can fast track it.

.iter()
.map(|f| PushedDownPredicate::unsupported(Arc::clone(f)))
.collect(),
parent_filters,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏻

) -> Result<FilterPushdownPropagation<Arc<dyn ExecutionPlan>>> {
let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
result.updated_node = Some(Arc::new(GlobalLimitExec::new(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
result.updated_node = Some(Arc::new(GlobalLimitExec::new(
result.updated_node = Some(Arc::new(Self::new(

?

let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
result.updated_node =
Some(Arc::new(LocalLimitExec::new(updated_child, self.fetch)) as _);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

Comment on lines +436 to +442
let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
let mut new_self = self.clone();
new_self.input = updated_child;
result.updated_node = Some(Arc::new(new_self) as _);
}
Ok(result)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏻

Comment on lines -1204 to 1211
Ok(FilterPushdownPropagation::if_all(child_pushdown_result))
let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
let mut new_self = self.clone();
new_self.input = updated_child;
result.updated_node = Some(Arc::new(new_self) as _);
}
Ok(result)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏻

Comment on lines +1435 to +1448
fn handle_child_pushdown_result(
&self,
_phase: FilterPushdownPhase,
child_pushdown_result: ChildPushdownResult,
_config: &datafusion_common::config::ConfigOptions,
) -> Result<FilterPushdownPropagation<Arc<dyn ExecutionPlan>>> {
let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
let mut new_self = self.cloned();
new_self.input = updated_child;
result.updated_node = Some(Arc::new(new_self) as _);
}
Ok(result)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really need to eliminate this foot gun 🦶🏻

Comment on lines -280 to +286
Ok(FilterPushdownPropagation::if_all(child_pushdown_result))
let mut result = FilterPushdownPropagation::if_all(child_pushdown_result);
if let Some(updated_child) = result.updated_node {
let mut new_self = self.clone();
new_self.input = updated_child;
result.updated_node = Some(Arc::new(new_self) as _);
}
Ok(result)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate 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.

Support filter pushdown through SortMergeJoinExec

6 participants