D8LooPFocus modeCODE WORKSPACE
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
| partition_day | row_count | size_mb |
|---|---|---|
| 2026-01-01 | 900 | 36 |
| 2026-01-02 | 1100 | 44 |
| 2026-01-03 | 800 | 32 |
| 2026-01-04 | 4200 | 168 |
| 2026-01-05 | 1000 | 40 |
| 2026-01-06 | 3000 | 120 |
| 2026-01-07 | 1200 | 48 |
| 2026-01-08 | 800 | 32 |
Expected output
| partitions_scanned | mb_scanned | partitions_total | mb_total |
|---|---|---|---|
| 3 | 240 | 8 | 520 |
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.
Run the SQL query to inspect preview rows.