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