Describe a time you had to optimize a slow-running SQL query that was impacting production performance. What was your approach?