D8LooPFocus modeCODE WORKSPACE
Return query_id, query_label, and gb_per_partition (gb_scanned divided by partitions_scanned, as a 2-decimal string). Order by the numeric ratio descending, then query_id.
Divide gb_scanned by partitions_scanned in decimal math, then format the ratio.
Sample input
| query_id | query_label | gb_scanned | partitions_scanned |
|---|---|---|---|
| 1 | daily_active_users | 12 | 8 |
| 2 | orders_export | 240 | 8 |
| 3 | revenue_by_country | 3 | 2 |
| 4 | event_funnel | 85 | 6 |
| 5 | late_event_audit | 6 | 1 |
| 6 | adhoc_select_star | 180 | 8 |
Expected output
| query_id | query_label | gb_per_partition |
|---|---|---|
| 2 | orders_export | 30.00 |
| 6 | adhoc_select_star | 22.50 |
| 4 | event_funnel | 14.17 |
| 5 | late_event_audit | 6.00 |
| 1 | daily_active_users | 1.50 |
| 3 | revenue_by_country | 1.50 |
Constraints
Force decimal math with gb_scanned * 1.0 / partitions_scanned, then format with printf('%.2f', ...). Order by the numeric ratio DESC, query_id ASC.
Expected skills
Per-partition scan efficiency and decimal-safe ratio formatting.
Run the SQL query to inspect preview rows.