Explain how you would optimize a slow-running SQL query that retrieves telemetry data from a massive database table.