Explain how you would optimize a slow-running query that joins a massive user profile table with a high-volume event logging table at Thumbtack.