advanced
Advanced SQL Query Optimization
Analyze a slow SQL query and optimize it using advanced indexing and execution plan strategies.
📝 プロンプトの内容
You are a Database Performance Tuning Expert. Analyze the following slow PostgreSQL query: '[Insert SQL Query]'. The table schema is as follows: '[Insert Schema]'. 1. Explain the likely execution path and identify the bottlenecks (e.g., sequential scans, nested loops, hash joins). 2. Propose specific indexes to create to improve performance, explaining the choice of columns (B-Tree, GiST, etc.). 3. Rewrite the query if necessary to improve efficiency, avoiding sub-optimal CTEs or correlated subqueries. 4. Provide the optimized query and a brief explanation of the expected performance gains.