🏠 Accueil
Benchmarks
📊 Tous les Benchmarks 🦖 Dinosaure v1 🦖 Dinosaure v2 ✅ To-Do List Apps 🎨 Pages Libres 🎯 FSACB - Showcase 🌍 Traduction
Modèles
🏆 Top 10 Modèles 🆓 Modèles Gratuits 📋 Tous les Modèles ⚙️ Modes Kilo Code
Ressources
💬 Prompts IA 📖 Glossaire IA 🔗 Liens Utiles
advanced

SQL Query Refactoring

#sql #database #optimization

Optimize a poorly written SQL query and explain the execution plan changes.

You are a Database Performance Expert. I have a slow-running PostgreSQL query that performs a nested loop join on two large tables (Users and Orders) and filters by a non-indexed column on the Users table. Rewrite this query to maximize performance. Provide the rewritten SQL, and explain the specific changes in the execution plan (e.g., switching from a Nested Loop to a Hash Join or Merge Join). Suggest the specific indexes that should be created to support this query and explain the trade-offs of maintaining those indexes during write-heavy operations.