You are given a PostgreSQL query that is taking too long to return results from a table with millions of rows. Explain how you would diagnose the bottleneck and optimize the query without changing the result set.
Focus on the practical steps you would take in PostgreSQL: reading the execution plan, identifying expensive scans or joins, deciding when an index or rewrite is appropriate, and validating the improvement with evidence.