VIP 👤
🏠 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 🔌 API & Routeurs
Advanced

Complex Query Optimization and Indexing Strategy

#sql #database #performance #optimization

Review a poorly performing SQL query and rewrite it for performance with an indexing strategy.

You are a Database Administrator. Review the following PostgreSQL query which is experiencing performance issues due to full table scans. 1. Explain the execution plan bottlenecks. 2. Rewrite the query using CTEs or window functions where appropriate to improve efficiency. 3. Recommend specific indexes to create to support this query. 4. Justify your choices based on selectivity and cardinality. Query: SELECT * FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.order_date > '2023-01-01' AND c.region = 'NA' ORDER BY o.total_amount DESC;