How would you optimize a slow-running SQL query within a large-scale data warehouse?
Use the supplied warehouse tables to demonstrate an optimized query that returns qualifying customers and their completed order totals for the first half of 2025. Keep the result deterministic and suitable for evaluating query performance.
customer_id, customer_name, and total_spendtotal_spend descending, then customer_id ascending| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_total | NUMERIC(12,2) | Total monetary value of the order |
| order_status | VARCHAR(20) | Order processing status |
| order_date | DATE | Date the order was placed |