VIP 👤
🏠 홈
벤치마크
📊 모든 벤치마크 🦖 공룡 v1 🦖 공룡 v2 ✅ 할 일 목록 앱 🎨 창의적인 자유 페이지 🎯 FSACB - 궁극의 쇼케이스 🌍 번역 벤치마크
모델
🏆 톱 10 모델 🆓 무료 모델 📋 모든 모델 ⚙️ 킬로 코드 모드
리소스
💬 프롬프트 라이브러리 📖 AI 용어 사전 🔗 유용한 링크 🔌 AI API 및 라우터
advanced

Advanced SQL Query Refactoring

#sql #optimization #database #performance

Optimize a highly inefficient, complex SQL query involving multiple joins and subqueries for a large dataset.

Given a hypothetical poorly performing SQL query that selects data from five tables (Orders, Customers, Products, Shipments, and Reviews) using several nested correlated subqueries and wildcard selects in a WHERE clause, rewrite the query for maximum performance on a PostgreSQL database. Assume the tables contain millions of rows. Explain your optimization steps, including: index usage strategies, replacing subqueries with JOINs or CTEs (Common Table Expressions), eliminating SELECT *, and utilizing window functions if applicable. Provide the final optimized SQL code and a brief explanation of the execution plan improvements.