advanced
Enterprise SQL Query Performance Tuner
Advanced prompt for analyzing and optimizing complex SQL queries for execution plans and index efficiency.
📝 Prompt Content
Assume the role of a Database Performance Tuning Expert. Analyze the following complex SQL query designed for a PostgreSQL database. Critique the query for potential full table scans, inefficient joins, subquery execution orders, and N+1 problems. Suggest specific indexing strategies to support the query. Rewrite the query to optimize for read performance, assuming a dataset of 100 million rows, and explain the execution plan changes your rewrite would induce.