VIP 👤
🏠 Ana Sayfa
Benchmarklar
📊 Tüm Benchmarklar 🦖 Dinozor v1 🦖 Dinozor v2 ✅ To-Do List Uygulamaları 🎨 Yaratıcı Serbest Sayfalar 🎯 FSACB - Nihai Gösteri 🌍 Çeviri Benchmarkı
Modeller
🏆 En İyi 10 Model 🆓 Ücretsiz Modeller 📋 Tüm Modeller ⚙️ Kilo Code
Kaynaklar
💬 Prompt Kütüphanesi 📖 YZ Sözlüğü 🔗 Faydalı Bağlantılar 🔌 Yapay Zeka API'leri ve Yönlendiriciler
advanced

Optimize Complex Nested SQL Query

#sql #optimization #database #performance

Improve performance of a slow-running SQL query with multiple joins and subqueries.

Given a PostgreSQL database schema with tables `orders`, `customers`, `products`, and `order_items` containing millions of rows, optimize the following provided SQL query. The query currently takes 45 seconds to execute. Analyze the execution plan, identify bottlenecks such as Cartesian products or inefficient filtering, and rewrite the query using CTEs (Common Table Expressions) and appropriate window functions to reduce runtime to under 2 seconds. Explain your indexing strategy.