Describe your experience with SQL. How would you optimize a query that is running slowly on a massive dataset?