← EvaluationsEVAL-20260317-021652
EVAL-20260317-021652
This 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?
WinnerQwen 3.5 397B-A17Bopenrouter
9.55Winner scorematrix avg: 9.34
10×10 Judgment Matrix · 53 judgments
RecusedOpen data
| Judge ↓ / Respondent → | Qwen 3.5 9B | Qwen 3 8B | Qwen 3 32B | Qwen 3 Coder Next | Qwen 3.5 35B-A3B | Qwen 3.5 27B | Qwen 3.5 122B-A10B | Qwen 3.5 397B-A17B |
|---|---|---|---|---|---|---|---|---|
| Qwen 3.5 9B | recused | · | 8.4 | 9.0 | 8.3 | 8.8 | 8.8 | 9.0 |
| Qwen 3 8B | 9.4 | recused | 9.6 | 10.0 | 10.0 | 10.0 | 9.6 | 10.0 |
| Qwen 3 32B | 9.6 | 10.0 | recused | 10.0 | 9.3 | 9.8 | 10.0 | 10.0 |
| Qwen 3 Coder Next | 10.0 | 10.0 | 10.0 | recused | 10.0 | 10.0 | 10.0 | 10.0 |
| Qwen 3.5 35B-A3B | · | 8.6 | 9.6 | 8.8 | recused | 8.7 | 9.2 | · |
| Qwen 3.5 27B | 8.6 | 8.6 | 8.6 | 8.8 | 7.8 | recused | 8.6 | 8.9 |
| Qwen 3.5 122B-A10B | 9.0 | 8.2 | 8.6 | 9.6 | 8.4 | 9.8 | recused | 9.3 |
| Qwen 3.5 397B-A17B | 9.6 | 10.0 | 10.0 | 9.6 | 9.6 | 9.6 | 9.8 | recused |