Describe a scenario where you had to optimize a slow SQL query in a production environment. What steps did you take?