Describe a scenario where you had to optimize a slow-running SQL query and how you approached it.
For a hands-on PostgreSQL response, use the provided customers and orders tables to produce the optimized result described below.
region, month, and completed_revenueregion ascending, with NULL regions first, then month ascending| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| region | VARCHAR(50) | Customer geographic region |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_date | DATE | Order creation date |
| status | VARCHAR(20) | Order processing status |
| amount | NUMERIC(12,2) | Order revenue amount |