How would you optimize a slow SQL query caused by multiple heavy joins on million-row transaction tables in a Robinhood-style dataset?