How would you optimize a slow-performing SQL query that involves multiple large table joins and aggregations?