VIP 👤
🏠 Trang chủ
Benchmark
📊 Tất cả benchmark 🦖 Khủng long v1 🦖 Khủng long v2 ✅ Ứng dụng To-Do List 🎨 Trang tự do sáng tạo 🎯 FSACB - Trình diễn cuối cùng 🌍 Benchmark dịch thuật
Mô hình
🏆 Top 10 mô hình 🆓 Mô hình miễn phí 📋 Tất cả mô hình ⚙️ Kilo Code
Tài nguyên
💬 Thư viện prompt 📖 Thuật ngữ AI 🔗 Liên kết hữu ích 🔌 API và bộ định tuyến AI
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;