How would you optimize a slow-running query in SQL?
Using the provided PostgreSQL tables, return customers whose completed orders total at least 1,000 during the first quarter of 2025. Rows with a NULL status, order date, amount, or customer reference are ignored.
customer_id, customer_name, total_spend, and completed_orders.total_spend descending, then customer_id ascending.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| region | VARCHAR(50) | Customer region |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_date | DATE | Order placement date |
| status | VARCHAR(20) | Order processing status |
| amount | NUMERIC(12,2) | Order amount |