CODE WORKSPACE

Partition pruning scan

Return partitions_scanned, mb_scanned, partitions_total, and mb_total for a partition_day range of 2026-01-03 to 2026-01-05.

Aggregate the in-range partitions, then add scalar subqueries for the full-table totals.

Sample input

table_partitionsEight daily partitions of the events table, with rows and size in MB.
partition_dayrow_countsize_mb
2026-01-0190036
2026-01-02110044
2026-01-0380032
2026-01-044200168
2026-01-05100040
2026-01-063000120
2026-01-07120048
2026-01-0880032

Expected output

Expected outputA 3-day filter reads 3 of 8 partitions and 240 of 520 MB.
partitions_scannedmb_scannedpartitions_totalmb_total
32408520

Constraints

Filter table_partitions on partition_day BETWEEN '2026-01-03' AND '2026-01-05'. Use COUNT(*) and SUM(size_mb) for the scanned figures, and scalar subqueries over the full table for the totals.

Expected skills

Partition pruning reasoning and quantifying scanned vs total data.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.