Walk me through your process for optimizing a slow-running query in BigQuery.
For the hands-on portion, use the supplied PostgreSQL tables and produce the optimized result query. Discuss how you would inspect the execution plan, reduce scanned rows, validate correctness, and confirm an improvement.
query_name, owner_team, run_date, run_count, avg_duration_ms, and total_bytes_processed.query_name, then run_date.| Column | Type | Description |
|---|---|---|
| run_idPK | INT | Unique query execution identifier |
| query_id | INT | Referenced query definition |
| started_at | TIMESTAMP | Execution start timestamp |
| duration_ms | INT | Execution duration in milliseconds |
| bytes_processed | BIGINT | Bytes processed by the execution |
| status | VARCHAR(20) | Execution status |
| Column | Type | Description |
|---|---|---|
| query_idPK | INT | Unique query definition identifier |
| query_name | VARCHAR(100) | Human-readable query name |
| owner_team | VARCHAR(80) | Team responsible for the query |
| is_active | BOOLEAN | Whether the query definition is active |