CODE WORKSPACE

Full-scan detector

Return query_id, query_label, and partitions_scanned for queries whose partitions_scanned equals the table's partition count. Order by query_id.

Compare each run's partitions_scanned to the total partition count from table_partitions.

Sample input

query_runspartitions_scanned per run; the events table has 8 partitions.
query_idquery_labelpartitions_scanned
1daily_active_users8
2orders_export8
3revenue_by_country2
4event_funnel6
5late_event_audit1
6adhoc_select_star8
table_partitions8 partitions in total, so the full-scan threshold is 8.
partition_day
2026-01-01
2026-01-04
2026-01-08

Expected output

Expected outputQueries that scanned all 8 partitions (no pruning happened).
query_idquery_labelpartitions_scanned
1daily_active_users8
2orders_export8
6adhoc_select_star8

Constraints

Compare partitions_scanned to (SELECT COUNT(*) FROM table_partitions). Keep only the equal rows and order by query_id.

Expected skills

Full-scan detection from query history and partition metadata.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.