Walk me through a complex SQL query you wrote recently. What optimization techniques did you use to improve its performance?