How do you approach optimizing a slow-running SQL query when dealing with massive transactional datasets?