🏠 Home
Benchmark Hub
📊 All Benchmarks 🦖 Dinosaur v1 🦖 Dinosaur v2 ✅ To-Do List Applications 🎨 Creative Free Pages 🎯 FSACB - Ultimate Showcase 🌍 Translation Benchmark
Models
🏆 Top 10 Models 🆓 Free Models 📋 All Models ⚙️ Kilo Code
Resources
💬 Prompts Library 📖 AI Glossary 🔗 Useful Links
Advanced

Legacy SQL Refactoring

#sql #database-optimization #performance

Optimize a poorly performing SQL query with complex joins.

Analyze the provided PostgreSQL query which performs a recursive CTE operation on a table with 50 million rows. The current execution plan shows a Nested Loop that is causing severe performance degradation. Rewrite the query to eliminate the recursive CTE by using set-based operations or window functions. Additionally, recommend the exact indexing strategy required to support the new query structure, specifying index types (e.g., B-Tree, GIN) and the columns to include.