✔ PASS Temporal & Time-Series task_024_Q24_sargable_fiscal_partition_prune Scaled: 1M+ Records Ordered: Yes

SARGable Fiscal Year Date Range Partition Pruning

Candidate Latency (1M Rows)
192.75 ms
(1.1x slower than golden)
Golden Latency (1M Rows)
181.07 ms
DuckDB in-memory engine
Underlying Data Volume
1,000,000 rows
30.5 MiB across 1 table
Evaluated Model
gemini-3.8-flash-low
Gen Latency: 14.2s
✔ Correctness Verified on 1M+ Records
Candidate SQL output matches ground truth golden query across all multiset rows and numeric tolerances (tol=1e-3). Zero data skew or anti-patterns detected on full dataset scale.

1. Analytical Significance & What It Means

Scenario & Frontier Trap
Business Scenario & Problem

Data warehouses partition petabyte event tables by date. Wrapping date columns in functions (e.g. `WHERE strftime('%Y', event_time) = '2026'`) breaks partition pruning, forcing a full table scan.

⚡ The Frontier Trap (Why LLMs Fail)

Non-SARGable functions force DuckDB/Snowflake to scan every Parquet row group.

Prompt / User Request Given to Model
Data warehouses partition petabyte event tables by date. Wrapping date columns in functions (e.g. `WHERE strftime('%Y', event_time) = '2026'`) breaks partition pruning, forcing a full table scan.

Execute the required analytical SQL calculation in DuckDB.
Expected output columns: event_id, event_timestamp, payload.
Results should be ordered as specified.

2. Underlying Tables, Row Counts & Data Volume

1 Tables (1,000,000 rows • 30.5 MiB)

Production-scale fixtures loaded into the isolated DuckDB sandbox with at least 1,000,000 records per table:

📊 telemetry_partitions 1,000,000 rows 30.5 MiB Data Volume
event_id (INTEGER) event_timestamp (TIMESTAMP) payload (VARCHAR)
Data Preview (showing sample rows from 1,000,000 total rows):
# event_id event_timestamp payload
1 1 2025-12-31 23:59:59 old
2 2 2026-01-01 00:00:00 target_start
3 3 2026-06-15 12:00:00 target_mid
4 4 2027-01-01 00:00:00 out_of_bounds
5 4 2026-03-01 09:30:00.000006 old
6 5 2026-03-01 09:30:00.000024 target_start
7 6 2026-03-01 09:30:00.000043 target_mid
8 7 2026-03-01 09:30:00.000061 out_of_bounds
9 8 2026-03-01 09:30:00.000091 old
10 9 2026-03-01 09:30:00.000108 target_start
11 10 2026-03-01 09:30:00.000134 target_mid
12 11 2026-03-01 09:30:00.000150 out_of_bounds
13 12 2026-03-01 09:30:00.000166 old
14 13 2026-03-01 09:30:00.000189 target_start
15 14 2026-03-01 09:30:00.000209 target_mid

3. Graphical Query Execution Plan & Cost Bottlenecks

Physical Operator Tree (DuckDB 2.0 Profiler)

Visual flowchart of the physical execution pipeline. Operators with high relative costs (≥ 20% of query runtime or heavy latency) are visually highlighted:

Pipeline Latency Distribution (Total Plan Time: 115.94 ms) Nodes consuming ≥ 20% of query runtime are highlighted with glowing borders
📐 PROJECTION 12.3%
Latency: 14.21 ms
Rows In/Out: 999,998
Data Vol: 26.70 MB
📁 Projections: ['#0', '#1', '__int...
⏳ ORDER_BY 🔥 69.2% Cost
Latency: 80.24 ms
Rows In/Out: 999,998
Data Vol: 26.70 MB
⚠️ Heavy Execution Bottleneck (69.2% of query runtime)
📐 PROJECTION 9.1%
Latency: 10.56 ms
Rows In/Out: 999,998
Data Vol: 26.70 MB
📁 Projections: ['#0', '#1', '__int...
📐 PROJECTION 0.1%
Latency: 0.14 ms
Rows In/Out: 999,998
Data Vol: 26.70 MB
📁 Projections: ['event_id', 'event...
🔍 TABLE_SCAN 9.3%
Latency: 10.81 ms
Rows In/Out: 999,998
Data Vol: 26.70 MB
📁 memory.main.telemetry_partitions
Operator Cost % Latency Processed Rows Data Volume Details / Table Status
ORDER_BY 69.2% 80.24 ms 999,998 26.70 MB - 🔥 BOTTLENECK
PROJECTION 12.3% 14.21 ms 999,998 26.70 MB Projections: ['#0', '#1', '__internal_decompress Normal
TABLE_SCAN 9.3% 10.81 ms 999,998 26.70 MB memory.main.telemetry_partitions Normal
PROJECTION 9.1% 10.56 ms 999,998 26.70 MB Projections: ['#0', '#1', '__internal_compress_s Normal
PROJECTION 0.1% 0.14 ms 999,998 26.70 MB Projections: ['event_id', 'event_timestamp', 'pa Normal

4. Queries Executed (Candidate vs Golden Ground Truth)

Beautified & Syntax Highlighted
Candidate SQL Executed by gemini-3.8-flash-low (Runtime on 1M Rows: 192.75 ms)
SELECT event_id,
       event_timestamp,
       payload
FROM telemetry_partitions
WHERE event_timestamp >= TIMESTAMP '2026-01-01 00:00:00'
  AND event_timestamp < TIMESTAMP '2027-01-01 00:00:00'
ORDER BY event_timestamp;
Golden Reference Ground Truth SQL (Runtime on 1M Rows: 181.07 ms)
-- Exact SARGable half-open date boundary pruning

SELECT event_id,
       event_timestamp,
       payload
FROM telemetry_partitions
WHERE event_timestamp >= TIMESTAMP '2026-01-01 00:00:00'
  AND event_timestamp < TIMESTAMP '2027-01-01 00:00:00'
ORDER BY event_timestamp;
DuckDB Fixture Setup DDL & Data Population
CREATE TABLE telemetry_partitions (event_id INT, event_timestamp TIMESTAMP, payload VARCHAR);


INSERT INTO telemetry_partitions
VALUES (1, '2025-12-31 23:59:59', 'old'),
       (2, '2026-01-01 00:00:00', 'target_start'),
       (3, '2026-06-15 12:00:00', 'target_mid'),
       (4, '2027-01-01 00:00:00', 'out_of_bounds');

5. Query Results & Expected Ground Truth

Tabular Comparison
Actual Candidate Output (999,998 rows × 3 cols)
# event_id event_timestamp payload
1 2 2026-01-01 00:00:00 target_start
2 4 2026-03-01 09:30:00.000006 old
3 5 2026-03-01 09:30:00.000024 target_start
4 6 2026-03-01 09:30:00.000043 target_mid
5 7 2026-03-01 09:30:00.000061 out_of_bounds
6 8 2026-03-01 09:30:00.000091 old
7 9 2026-03-01 09:30:00.000108 target_start
8 10 2026-03-01 09:30:00.000134 target_mid
9 11 2026-03-01 09:30:00.000150 out_of_bounds
10 12 2026-03-01 09:30:00.000166 old
11 13 2026-03-01 09:30:00.000189 target_start
12 14 2026-03-01 09:30:00.000209 target_mid
13 15 2026-03-01 09:30:00.000230 out_of_bounds
14 16 2026-03-01 09:30:00.000247 old
15 17 2026-03-01 09:30:00.000268 target_start
16 18 2026-03-01 09:30:00.000281 target_mid
17 19 2026-03-01 09:30:00.000303 out_of_bounds
18 20 2026-03-01 09:30:00.000324 old
19 21 2026-03-01 09:30:00.000341 target_start
20 22 2026-03-01 09:30:00.000363 target_mid
21 23 2026-03-01 09:30:00.000381 out_of_bounds
22 24 2026-03-01 09:30:00.000404 old
23 25 2026-03-01 09:30:00.000425 target_start
24 26 2026-03-01 09:30:00.000461 target_mid
25 27 2026-03-01 09:30:00.000465 out_of_bounds
Showing first 25 of 999,998 total rows.
Expected Golden Output (999,998 rows × 3 cols)
# event_id event_timestamp payload
1 2 2026-01-01 00:00:00 target_start
2 4 2026-03-01 09:30:00.000006 old
3 5 2026-03-01 09:30:00.000024 target_start
4 6 2026-03-01 09:30:00.000043 target_mid
5 7 2026-03-01 09:30:00.000061 out_of_bounds
6 8 2026-03-01 09:30:00.000091 old
7 9 2026-03-01 09:30:00.000108 target_start
8 10 2026-03-01 09:30:00.000134 target_mid
9 11 2026-03-01 09:30:00.000150 out_of_bounds
10 12 2026-03-01 09:30:00.000166 old
11 13 2026-03-01 09:30:00.000189 target_start
12 14 2026-03-01 09:30:00.000209 target_mid
13 15 2026-03-01 09:30:00.000230 out_of_bounds
14 16 2026-03-01 09:30:00.000247 old
15 17 2026-03-01 09:30:00.000268 target_start
16 18 2026-03-01 09:30:00.000281 target_mid
17 19 2026-03-01 09:30:00.000303 out_of_bounds
18 20 2026-03-01 09:30:00.000324 old
19 21 2026-03-01 09:30:00.000341 target_start
20 22 2026-03-01 09:30:00.000363 target_mid
21 23 2026-03-01 09:30:00.000381 out_of_bounds
22 24 2026-03-01 09:30:00.000404 old
23 25 2026-03-01 09:30:00.000425 target_start
24 26 2026-03-01 09:30:00.000461 target_mid
25 27 2026-03-01 09:30:00.000465 out_of_bounds
Showing first 25 of 999,998 total rows.
← Prev: Outlier-Resistant Rolling... ⊞ Back to Benchmark Dashboard Next: Multi-Touch Marketing Att... →