How would you optimize a SQL query designed to extract patient cohort data from a massive claims database at Humana?