How would you optimize a slow-running SQL query that involves multiple table joins and aggregations in a production system?