How would you optimize a complex SQL query that is running slowly on a massive clinical dataset at Verily?