Explain how you would optimize a slow-running query that joins a massive table of daily user events with a dimension table.