Analyze and optimize a SQL query for performance. Returns rewritten query, index recommendations, and explanation of improvements.