Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Oct 30, 2025

Which issue does this PR close?

Rationale for this change

While messing arund with the push decoder in

I stumbled upon the ParquetRecordBatchStream::next_row_group API added by @Xuanwo upstream in parquet:

This API allows starting the IO work for the next reader while processing the current reader which should
allow better overlapping of IO and CPU work.

I figured I would give it a quick test in DataFusion to see if it actually helps.

What changes are included in this PR?

Add a prefetch stream that uses ParquetRecordBatchStream::next_row_group

Note: this will buffer more memory (potentially has an extra row group fetched in practice)

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the datasource Changes to the datasource crate label Oct 30, 2025
@alamb
Copy link
Contributor Author

alamb commented Oct 30, 2025

🤖 ./gh_compare_branch.sh Benchmark Script Running
Linux aal-dev 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Comparing alamb/prefetch_row_groups (e773e91) to 607325a diff using: clickbench_pushdown
Results will be posted here when complete

{
pub fn new(stream: ParquetRecordBatchStream<T>) -> Self {
Self {
state: EagerPrefetchState::next_row_group(stream),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in real code, this shouldn't start until the first batch is requested I suspect

@alamb
Copy link
Contributor Author

alamb commented Oct 30, 2025

🤖: Benchmark completed

Details

Comparing HEAD and alamb_prefetch_row_groups
--------------------
Benchmark clickbench_pushdown.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query        ┃        HEAD ┃ alamb_prefetch_row_groups ┃        Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0     │     2.76 ms │                   2.81 ms │     no change │
│ QQuery 1     │    54.49 ms │                  51.45 ms │ +1.06x faster │
│ QQuery 2     │   136.74 ms │                 140.55 ms │     no change │
│ QQuery 3     │   163.25 ms │                 150.59 ms │ +1.08x faster │
│ QQuery 4     │  1057.28 ms │                1268.61 ms │  1.20x slower │
│ QQuery 5     │  1516.79 ms │                1703.05 ms │  1.12x slower │
│ QQuery 6     │     2.79 ms │                   2.29 ms │ +1.22x faster │
│ QQuery 7     │    73.91 ms │                  66.43 ms │ +1.11x faster │
│ QQuery 8     │  1438.49 ms │                1587.57 ms │  1.10x slower │
│ QQuery 9     │  1884.87 ms │                1909.48 ms │     no change │
│ QQuery 10    │   497.14 ms │                 505.08 ms │     no change │
│ QQuery 11    │   573.33 ms │                 556.83 ms │     no change │
│ QQuery 12    │  1574.61 ms │                1702.14 ms │  1.08x slower │
│ QQuery 13    │  2511.95 ms │                2621.81 ms │     no change │
│ QQuery 14    │  1692.76 ms │                1685.45 ms │     no change │
│ QQuery 15    │  1213.54 ms │                1355.25 ms │  1.12x slower │
│ QQuery 16    │  2642.39 ms │                2754.08 ms │     no change │
│ QQuery 17    │  2652.39 ms │                2732.06 ms │     no change │
│ QQuery 18    │  4880.10 ms │                5030.49 ms │     no change │
│ QQuery 19    │   150.98 ms │                 128.87 ms │ +1.17x faster │
│ QQuery 20    │  1991.06 ms │                1931.54 ms │     no change │
│ QQuery 21    │  2521.16 ms │                2317.17 ms │ +1.09x faster │
│ QQuery 22    │  4199.03 ms │                4004.83 ms │     no change │
│ QQuery 23    │  1159.64 ms │                1252.93 ms │  1.08x slower │
│ QQuery 24    │   263.44 ms │                 234.09 ms │ +1.13x faster │
│ QQuery 25    │   722.12 ms │                 619.72 ms │ +1.17x faster │
│ QQuery 26    │   366.48 ms │                 335.47 ms │ +1.09x faster │
│ QQuery 27    │  3182.51 ms │                3124.72 ms │     no change │
│ QQuery 28    │ 23668.27 ms │               23754.28 ms │     no change │
│ QQuery 29    │   975.13 ms │                 990.16 ms │     no change │
│ QQuery 30    │  2172.76 ms │                2147.25 ms │     no change │
│ QQuery 31    │  2089.65 ms │                2088.47 ms │     no change │
│ QQuery 32    │  4630.22 ms │                4337.73 ms │ +1.07x faster │
│ QQuery 33    │  5903.03 ms │                5754.42 ms │     no change │
│ QQuery 34    │  6612.56 ms │                6143.61 ms │ +1.08x faster │
│ QQuery 35    │  2123.00 ms │                2086.54 ms │     no change │
│ QQuery 36    │    26.49 ms │                  18.69 ms │ +1.42x faster │
│ QQuery 37    │    26.22 ms │                  18.02 ms │ +1.45x faster │
│ QQuery 38    │    26.26 ms │                  17.90 ms │ +1.47x faster │
│ QQuery 39    │    25.51 ms │                  18.54 ms │ +1.38x faster │
│ QQuery 40    │    26.89 ms │                  19.22 ms │ +1.40x faster │
│ QQuery 41    │    26.08 ms │                  18.05 ms │ +1.44x faster │
│ QQuery 42    │    25.48 ms │                  18.35 ms │ +1.39x faster │
└──────────────┴─────────────┴───────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 87483.56ms │
│ Total Time (alamb_prefetch_row_groups)   │ 87206.58ms │
│ Average Time (HEAD)                      │  2034.50ms │
│ Average Time (alamb_prefetch_row_groups) │  2028.06ms │
│ Queries Faster                           │         18 │
│ Queries Slower                           │          6 │
│ Queries with No Change                   │         19 │
│ Queries with Failure                     │          0 │
└──────────────────────────────────────────┴────────────┘

@alamb
Copy link
Contributor Author

alamb commented Oct 30, 2025

🤖 ./gh_compare_branch.sh Benchmark Script Running
Linux aal-dev 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Comparing alamb/prefetch_row_groups (e773e91) to 607325a diff using: tpch_mem clickbench_partitioned clickbench_extended
Results will be posted here when complete

@alamb
Copy link
Contributor Author

alamb commented Oct 30, 2025

🤖: Benchmark completed

Details

Comparing HEAD and alamb_prefetch_row_groups
--------------------
Benchmark clickbench_extended.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query        ┃        HEAD ┃ alamb_prefetch_row_groups ┃    Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 0     │  2823.45 ms │                2784.58 ms │ no change │
│ QQuery 1     │  1371.93 ms │                1322.79 ms │ no change │
│ QQuery 2     │  2534.89 ms │                2497.29 ms │ no change │
│ QQuery 3     │  1186.66 ms │                1179.14 ms │ no change │
│ QQuery 4     │  2245.30 ms │                2233.54 ms │ no change │
│ QQuery 5     │ 28054.14 ms │               28501.99 ms │ no change │
│ QQuery 6     │  4266.42 ms │                4209.75 ms │ no change │
│ QQuery 7     │  3486.96 ms │                3544.71 ms │ no change │
└──────────────┴─────────────┴───────────────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 45969.76ms │
│ Total Time (alamb_prefetch_row_groups)   │ 46273.79ms │
│ Average Time (HEAD)                      │  5746.22ms │
│ Average Time (alamb_prefetch_row_groups) │  5784.22ms │
│ Queries Faster                           │          0 │
│ Queries Slower                           │          0 │
│ Queries with No Change                   │          8 │
│ Queries with Failure                     │          0 │
└──────────────────────────────────────────┴────────────┘
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query        ┃        HEAD ┃ alamb_prefetch_row_groups ┃        Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0     │     2.36 ms │                   2.27 ms │     no change │
│ QQuery 1     │    51.11 ms │                  48.95 ms │     no change │
│ QQuery 2     │   141.29 ms │                 135.05 ms │     no change │
│ QQuery 3     │   167.36 ms │                 154.86 ms │ +1.08x faster │
│ QQuery 4     │  1106.24 ms │                1057.82 ms │     no change │
│ QQuery 5     │  1559.60 ms │                1476.47 ms │ +1.06x faster │
│ QQuery 6     │     3.01 ms │                   2.19 ms │ +1.38x faster │
│ QQuery 7     │    59.08 ms │                  54.06 ms │ +1.09x faster │
│ QQuery 8     │  1500.60 ms │                1450.38 ms │     no change │
│ QQuery 9     │  1997.55 ms │                1858.25 ms │ +1.07x faster │
│ QQuery 10    │   403.92 ms │                 400.80 ms │     no change │
│ QQuery 11    │   462.15 ms │                 447.32 ms │     no change │
│ QQuery 12    │  1459.95 ms │                1419.69 ms │     no change │
│ QQuery 13    │  2244.78 ms │                2203.38 ms │     no change │
│ QQuery 14    │  1323.72 ms │                1275.75 ms │     no change │
│ QQuery 15    │  1239.85 ms │                1234.18 ms │     no change │
│ QQuery 16    │  2684.91 ms │                2690.00 ms │     no change │
│ QQuery 17    │  2707.13 ms │                2657.77 ms │     no change │
│ QQuery 18    │  5279.35 ms │                5321.36 ms │     no change │
│ QQuery 19    │   128.38 ms │                 131.67 ms │     no change │
│ QQuery 20    │  2064.79 ms │                2031.68 ms │     no change │
│ QQuery 21    │  2373.89 ms │                2304.80 ms │     no change │
│ QQuery 22    │  4088.61 ms │                3966.60 ms │     no change │
│ QQuery 23    │ 13086.42 ms │               12736.79 ms │     no change │
│ QQuery 24    │   233.64 ms │                 211.33 ms │ +1.11x faster │
│ QQuery 25    │   515.82 ms │                 493.73 ms │     no change │
│ QQuery 26    │   226.98 ms │                 212.15 ms │ +1.07x faster │
│ QQuery 27    │  2943.27 ms │                2840.49 ms │     no change │
│ QQuery 28    │ 22798.29 ms │               22635.28 ms │     no change │
│ QQuery 29    │   975.66 ms │                 974.08 ms │     no change │
│ QQuery 30    │  1364.53 ms │                1322.54 ms │     no change │
│ QQuery 31    │  1380.77 ms │                1340.24 ms │     no change │
│ QQuery 32    │  4490.85 ms │                4857.64 ms │  1.08x slower │
│ QQuery 33    │  6085.71 ms │                6030.40 ms │     no change │
│ QQuery 34    │  6528.18 ms │                6442.43 ms │     no change │
│ QQuery 35    │  2119.99 ms │                2051.75 ms │     no change │
│ QQuery 36    │   122.07 ms │                 117.19 ms │     no change │
│ QQuery 37    │    53.10 ms │                  52.29 ms │     no change │
│ QQuery 38    │   119.36 ms │                 115.93 ms │     no change │
│ QQuery 39    │   199.59 ms │                 190.85 ms │     no change │
│ QQuery 40    │    45.33 ms │                  42.53 ms │ +1.07x faster │
│ QQuery 41    │    37.85 ms │                  37.55 ms │     no change │
│ QQuery 42    │    32.68 ms │                  31.88 ms │     no change │
└──────────────┴─────────────┴───────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 96409.71ms │
│ Total Time (alamb_prefetch_row_groups)   │ 95062.36ms │
│ Average Time (HEAD)                      │  2242.09ms │
│ Average Time (alamb_prefetch_row_groups) │  2210.75ms │
│ Queries Faster                           │          8 │
│ Queries Slower                           │          1 │
│ Queries with No Change                   │         34 │
│ Queries with Failure                     │          0 │
└──────────────────────────────────────────┴────────────┘
--------------------
Benchmark tpch_mem_sf1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Query        ┃      HEAD ┃ alamb_prefetch_row_groups ┃       Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ QQuery 1     │ 171.28 ms │                 170.51 ms │    no change │
│ QQuery 2     │  27.34 ms │                  27.30 ms │    no change │
│ QQuery 3     │  41.46 ms │                  41.03 ms │    no change │
│ QQuery 4     │  29.93 ms │                  29.34 ms │    no change │
│ QQuery 5     │  81.54 ms │                  78.95 ms │    no change │
│ QQuery 6     │  20.01 ms │                  20.51 ms │    no change │
│ QQuery 7     │ 217.92 ms │                 224.19 ms │    no change │
│ QQuery 8     │  32.15 ms │                  35.18 ms │ 1.09x slower │
│ QQuery 9     │ 104.83 ms │                 106.04 ms │    no change │
│ QQuery 10    │  63.13 ms │                  63.51 ms │    no change │
│ QQuery 11    │  17.58 ms │                  17.53 ms │    no change │
│ QQuery 12    │  52.78 ms │                  51.65 ms │    no change │
│ QQuery 13    │  48.59 ms │                  47.58 ms │    no change │
│ QQuery 14    │  13.84 ms │                  14.03 ms │    no change │
│ QQuery 15    │  25.34 ms │                  24.75 ms │    no change │
│ QQuery 16    │  25.40 ms │                  25.16 ms │    no change │
│ QQuery 17    │ 154.56 ms │                 154.10 ms │    no change │
│ QQuery 18    │ 335.90 ms │                 329.76 ms │    no change │
│ QQuery 19    │  37.40 ms │                  37.05 ms │    no change │
│ QQuery 20    │  51.13 ms │                  49.64 ms │    no change │
│ QQuery 21    │ 331.96 ms │                 319.17 ms │    no change │
│ QQuery 22    │  20.14 ms │                  20.81 ms │    no change │
└──────────────┴───────────┴───────────────────────────┴──────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 1904.22ms │
│ Total Time (alamb_prefetch_row_groups)   │ 1887.79ms │
│ Average Time (HEAD)                      │   86.56ms │
│ Average Time (alamb_prefetch_row_groups) │   85.81ms │
│ Queries Faster                           │         0 │
│ Queries Slower                           │         1 │
│ Queries with No Change                   │        21 │
│ Queries with Failure                     │         0 │
└──────────────────────────────────────────┴───────────┘

@alamb
Copy link
Contributor Author

alamb commented Oct 31, 2025

🤖 ./gh_compare_branch.sh Benchmark Script Running
Linux aal-dev 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Comparing alamb/prefetch_row_groups (e773e91) to 607325a diff using: clickbench_pushdown
Results will be posted here when complete

@alamb
Copy link
Contributor Author

alamb commented Oct 31, 2025

🤖: Benchmark completed

Details

Comparing HEAD and alamb_prefetch_row_groups
--------------------
Benchmark clickbench_pushdown.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query        ┃        HEAD ┃ alamb_prefetch_row_groups ┃        Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0     │     2.56 ms │                   2.25 ms │ +1.14x faster │
│ QQuery 1     │    54.52 ms │                  49.73 ms │ +1.10x faster │
│ QQuery 2     │   140.87 ms │                 138.97 ms │     no change │
│ QQuery 3     │   164.70 ms │                 156.78 ms │     no change │
│ QQuery 4     │  1090.26 ms │                1042.83 ms │     no change │
│ QQuery 5     │  1508.79 ms │                1451.72 ms │     no change │
│ QQuery 6     │     2.20 ms │                   2.26 ms │     no change │
│ QQuery 7     │    70.68 ms │                  64.57 ms │ +1.09x faster │
│ QQuery 8     │  1435.73 ms │                1416.63 ms │     no change │
│ QQuery 9     │  1897.93 ms │                1784.60 ms │ +1.06x faster │
│ QQuery 10    │   493.35 ms │                 482.62 ms │     no change │
│ QQuery 11    │   572.32 ms │                 558.31 ms │     no change │
│ QQuery 12    │  1569.61 ms │                1480.79 ms │ +1.06x faster │
│ QQuery 13    │  2546.88 ms │                2423.75 ms │     no change │
│ QQuery 14    │  1650.95 ms │                1592.18 ms │     no change │
│ QQuery 15    │  1206.82 ms │                1214.39 ms │     no change │
│ QQuery 16    │  2623.99 ms │                2624.57 ms │     no change │
│ QQuery 17    │  2617.58 ms │                2653.60 ms │     no change │
│ QQuery 18    │  5288.80 ms │                4862.26 ms │ +1.09x faster │
│ QQuery 19    │   143.90 ms │                 129.09 ms │ +1.11x faster │
│ QQuery 20    │  1998.93 ms │                1888.85 ms │ +1.06x faster │
│ QQuery 21    │  2428.91 ms │                2259.22 ms │ +1.08x faster │
│ QQuery 22    │  4195.69 ms │                3945.80 ms │ +1.06x faster │
│ QQuery 23    │  1185.22 ms │                1174.87 ms │     no change │
│ QQuery 24    │   262.00 ms │                 244.40 ms │ +1.07x faster │
│ QQuery 25    │   694.76 ms │                 615.37 ms │ +1.13x faster │
│ QQuery 26    │   346.17 ms │                 323.69 ms │ +1.07x faster │
│ QQuery 27    │  3188.86 ms │                3020.59 ms │ +1.06x faster │
│ QQuery 28    │ 24187.59 ms │               23344.83 ms │     no change │
│ QQuery 29    │  1005.41 ms │                 984.78 ms │     no change │
│ QQuery 30    │  2188.45 ms │                2065.42 ms │ +1.06x faster │
│ QQuery 31    │  2069.10 ms │                2048.44 ms │     no change │
│ QQuery 32    │  4824.69 ms │                4395.26 ms │ +1.10x faster │
│ QQuery 33    │  5942.11 ms │                5610.59 ms │ +1.06x faster │
│ QQuery 34    │  6033.64 ms │                5988.40 ms │     no change │
│ QQuery 35    │  2079.90 ms │                2005.17 ms │     no change │
│ QQuery 36    │    25.56 ms │                  18.06 ms │ +1.42x faster │
│ QQuery 37    │    25.48 ms │                  17.54 ms │ +1.45x faster │
│ QQuery 38    │    25.57 ms │                  17.53 ms │ +1.46x faster │
│ QQuery 39    │    25.13 ms │                  17.77 ms │ +1.41x faster │
│ QQuery 40    │    26.99 ms │                  18.78 ms │ +1.44x faster │
│ QQuery 41    │    25.15 ms │                  18.17 ms │ +1.38x faster │
│ QQuery 42    │    25.46 ms │                  18.24 ms │ +1.40x faster │
└──────────────┴─────────────┴───────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 87893.21ms │
│ Total Time (alamb_prefetch_row_groups)   │ 84173.70ms │
│ Average Time (HEAD)                      │  2044.03ms │
│ Average Time (alamb_prefetch_row_groups) │  1957.53ms │
│ Queries Faster                           │         24 │
│ Queries Slower                           │          0 │
│ Queries with No Change                   │         19 │
│ Queries with Failure                     │          0 │
└──────────────────────────────────────────┴────────────┘

@alamb
Copy link
Contributor Author

alamb commented Oct 31, 2025

🤖 ./gh_compare_branch.sh Benchmark Script Running
Linux aal-dev 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Comparing alamb/prefetch_row_groups (e773e91) to 607325a diff using: tpch_mem clickbench_partitioned clickbench_extended
Results will be posted here when complete

@alamb
Copy link
Contributor Author

alamb commented Oct 31, 2025

🤖: Benchmark completed

Details

Comparing HEAD and alamb_prefetch_row_groups
--------------------
Benchmark clickbench_extended.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query        ┃        HEAD ┃ alamb_prefetch_row_groups ┃    Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 0     │  2815.07 ms │                2699.72 ms │ no change │
│ QQuery 1     │  1346.17 ms │                1297.14 ms │ no change │
│ QQuery 2     │  2520.90 ms │                2506.18 ms │ no change │
│ QQuery 3     │  1182.16 ms │                1158.12 ms │ no change │
│ QQuery 4     │  2221.49 ms │                2181.00 ms │ no change │
│ QQuery 5     │ 28008.30 ms │               27863.09 ms │ no change │
│ QQuery 6     │  4216.45 ms │                4199.96 ms │ no change │
│ QQuery 7     │  3386.36 ms │                3415.65 ms │ no change │
└──────────────┴─────────────┴───────────────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 45696.89ms │
│ Total Time (alamb_prefetch_row_groups)   │ 45320.86ms │
│ Average Time (HEAD)                      │  5712.11ms │
│ Average Time (alamb_prefetch_row_groups) │  5665.11ms │
│ Queries Faster                           │          0 │
│ Queries Slower                           │          0 │
│ Queries with No Change                   │          8 │
│ Queries with Failure                     │          0 │
└──────────────────────────────────────────┴────────────┘
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query        ┃        HEAD ┃ alamb_prefetch_row_groups ┃        Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0     │     2.72 ms │                   2.42 ms │ +1.12x faster │
│ QQuery 1     │    50.78 ms │                  49.66 ms │     no change │
│ QQuery 2     │   139.34 ms │                 138.37 ms │     no change │
│ QQuery 3     │   161.93 ms │                 159.52 ms │     no change │
│ QQuery 4     │  1121.27 ms │                1078.05 ms │     no change │
│ QQuery 5     │  1550.32 ms │                1505.49 ms │     no change │
│ QQuery 6     │     2.19 ms │                   2.13 ms │     no change │
│ QQuery 7     │    54.99 ms │                  54.84 ms │     no change │
│ QQuery 8     │  1472.34 ms │                1465.87 ms │     no change │
│ QQuery 9     │  1899.12 ms │                1836.18 ms │     no change │
│ QQuery 10    │   399.04 ms │                 390.73 ms │     no change │
│ QQuery 11    │   458.29 ms │                 431.21 ms │ +1.06x faster │
│ QQuery 12    │  1430.97 ms │                1385.64 ms │     no change │
│ QQuery 13    │  2225.72 ms │                2175.40 ms │     no change │
│ QQuery 14    │  1332.40 ms │                1274.84 ms │     no change │
│ QQuery 15    │  1219.37 ms │                1219.05 ms │     no change │
│ QQuery 16    │  2674.83 ms │                2630.83 ms │     no change │
│ QQuery 17    │  2675.25 ms │                2627.48 ms │     no change │
│ QQuery 18    │  4944.30 ms │                4900.53 ms │     no change │
│ QQuery 19    │   128.41 ms │                 118.56 ms │ +1.08x faster │
│ QQuery 20    │  1976.26 ms │                1932.37 ms │     no change │
│ QQuery 21    │  2312.85 ms │                2229.28 ms │     no change │
│ QQuery 22    │  3952.35 ms │                3888.29 ms │     no change │
│ QQuery 23    │ 12921.20 ms │               12603.65 ms │     no change │
│ QQuery 24    │   223.57 ms │                 217.05 ms │     no change │
│ QQuery 25    │   538.34 ms │                 496.36 ms │ +1.08x faster │
│ QQuery 26    │   217.52 ms │                 206.25 ms │ +1.05x faster │
│ QQuery 27    │  2877.62 ms │                2821.31 ms │     no change │
│ QQuery 28    │ 22809.30 ms │               22742.69 ms │     no change │
│ QQuery 29    │   993.56 ms │                 981.61 ms │     no change │
│ QQuery 30    │  1353.64 ms │                1306.34 ms │     no change │
│ QQuery 31    │  1368.91 ms │                1328.15 ms │     no change │
│ QQuery 32    │  4334.13 ms │                4285.84 ms │     no change │
│ QQuery 33    │  5831.41 ms │                5720.06 ms │     no change │
│ QQuery 34    │  6011.22 ms │                5855.95 ms │     no change │
│ QQuery 35    │  2043.61 ms │                2029.89 ms │     no change │
│ QQuery 36    │   120.19 ms │                 117.86 ms │     no change │
│ QQuery 37    │    51.83 ms │                  50.37 ms │     no change │
│ QQuery 38    │   121.53 ms │                 112.66 ms │ +1.08x faster │
│ QQuery 39    │   196.10 ms │                 188.77 ms │     no change │
│ QQuery 40    │    43.16 ms │                  38.74 ms │ +1.11x faster │
│ QQuery 41    │    38.36 ms │                  39.18 ms │     no change │
│ QQuery 42    │    33.10 ms │                  31.08 ms │ +1.07x faster │
└──────────────┴─────────────┴───────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 94313.34ms │
│ Total Time (alamb_prefetch_row_groups)   │ 92670.56ms │
│ Average Time (HEAD)                      │  2193.33ms │
│ Average Time (alamb_prefetch_row_groups) │  2155.13ms │
│ Queries Faster                           │          8 │
│ Queries Slower                           │          0 │
│ Queries with No Change                   │         35 │
│ Queries with Failure                     │          0 │
└──────────────────────────────────────────┴────────────┘
--------------------
Benchmark tpch_mem_sf1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query        ┃      HEAD ┃ alamb_prefetch_row_groups ┃        Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1     │ 178.15 ms │                 169.62 ms │     no change │
│ QQuery 2     │  27.12 ms │                  26.06 ms │     no change │
│ QQuery 3     │  41.92 ms │                  41.59 ms │     no change │
│ QQuery 4     │  29.16 ms │                  29.18 ms │     no change │
│ QQuery 5     │  78.41 ms │                  77.17 ms │     no change │
│ QQuery 6     │  19.79 ms │                  19.83 ms │     no change │
│ QQuery 7     │ 213.77 ms │                 221.48 ms │     no change │
│ QQuery 8     │  34.71 ms │                  36.13 ms │     no change │
│ QQuery 9     │  99.66 ms │                 100.06 ms │     no change │
│ QQuery 10    │  61.65 ms │                  62.06 ms │     no change │
│ QQuery 11    │  17.36 ms │                  17.20 ms │     no change │
│ QQuery 12    │  51.44 ms │                  51.30 ms │     no change │
│ QQuery 13    │  47.61 ms │                  46.83 ms │     no change │
│ QQuery 14    │  14.62 ms │                  14.18 ms │     no change │
│ QQuery 15    │  24.86 ms │                  25.19 ms │     no change │
│ QQuery 16    │  24.85 ms │                  25.62 ms │     no change │
│ QQuery 17    │ 151.17 ms │                 145.87 ms │     no change │
│ QQuery 18    │ 328.76 ms │                 331.27 ms │     no change │
│ QQuery 19    │  36.56 ms │                  37.19 ms │     no change │
│ QQuery 20    │  49.11 ms │                  49.93 ms │     no change │
│ QQuery 21    │ 353.45 ms │                 331.67 ms │ +1.07x faster │
│ QQuery 22    │  20.64 ms │                  21.41 ms │     no change │
└──────────────┴───────────┴───────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                        ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                        │ 1904.77ms │
│ Total Time (alamb_prefetch_row_groups)   │ 1880.82ms │
│ Average Time (HEAD)                      │   86.58ms │
│ Average Time (alamb_prefetch_row_groups) │   85.49ms │
│ Queries Faster                           │         1 │
│ Queries Slower                           │         0 │
│ Queries with No Change                   │        21 │
│ Queries with Failure                     │         0 │
└──────────────────────────────────────────┴───────────┘

@alamb
Copy link
Contributor Author

alamb commented Oct 31, 2025

The benchmark results actually look fairly promising. I'll try and confirm these results manually and then polish this PR up and mark it ready for review

@Dandandan
Copy link
Contributor

Might as well run some tests agains s3 / object store to see if performance improvement is even better?

self.state = EagerPrefetchState::Done;
} else {
// immediately start reading the next row group
self.state = EagerPrefetchState::next_row_group(stream);
Copy link
Contributor

Choose a reason for hiding this comment

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

Might even make this configurable (i.e. prefetch >=2 row groups?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call -- I will look into that. I am not sure buffering more than 1 row group will really help (if you have more than one reader buffered it means the rest of the plan can't consume the data fast enough (and we need to apply backpressure)

@alamb
Copy link
Contributor Author

alamb commented Nov 3, 2025

I filed #18391 to track this idea more

@Xuanwo
Copy link
Member

Xuanwo commented Nov 3, 2025

Cool!

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

Labels

datasource Changes to the datasource crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants