code
Mar 18, 2026EVAL-20260318-161904This SQL query takes 45 seconds on a table with 10M rows. Rewrite it to run in under 1 second. Explain your optimization strategy. ```sql SELECT u.name, u.email, (SELECT COUNT(*) FROM orders o WHERE o.user_id = u.id) as order_count, (SELECT SUM(amount) FROM orders o WHERE o.user_id = u.id) as total_spent, (SELECT MAX(created_at) FROM orders o WHERE o.user_id = u.id) as last_order FROM users u WHERE u.created_at > '2024-01-01' AND (SELECT COUNT(*) FROM orders o WHERE o.user_id = u.id) > 5 ORDER BY total_spent DESC LIMIT 100; ``` Assume standard B-tree indexes on primary keys only. What indexes would you add?
Winner
GPT-5.4
openrouter
9.72
WINNER SCORE
matrix avg: 8.27
10×10 Judgment Matrix · 56 judgments
OPEN DATA
| Judge ↓ / Respondent → | MiniMax M2.7 | MiniMax M2.5 | MiniMax M2.1 | MiniMax M2 | MiniMax M1 | MiniMax-01 | Claude Sonnet 4.6 | GPT-5.4 |
|---|---|---|---|---|---|---|---|---|
| MiniMax M2.7 | — | 8.8 | 7.1 | 4.9 | 10.0 | 8.6 | 9.8 | 9.6 |
| MiniMax M2.5 | 10.0 | — | 6.5 | 4.5 | 9.6 | 8.3 | 10.0 | 9.8 |
| MiniMax M2.1 | 9.2 | 8.6 | — | 2.1 | 10.0 | 8.1 | 10.0 | 10.0 |
| MiniMax M2 | 9.4 | 10.0 | 7.8 | — | 9.8 | 8.4 | 10.0 | 9.6 |
| MiniMax M1 | 9.8 | 9.6 | 8.3 | 4.3 | — | 7.3 | 10.0 | 10.0 |
| MiniMax-01 | 9.8 | 9.6 | 8.6 | 7.6 | 9.8 | — | 10.0 | 9.8 |
| Claude Sonnet 4.6 | 8.6 | 9.2 | 5.7 | 5.0 | 9.3 | 8.0 | — | 9.3 |
| GPT-5.4 | 7.0 | 7.0 | 5.2 | 2.5 | 7.2 | 6.6 | 7.8 | — |