How would you optimize a query that joins a massive user profile table with a high-volume transaction ledger?