Explain how you would optimize a slow-running SQL query that joins multiple large tables in a production environment.