Describe a scenario where you had to optimize a slow-performing database query. What was your approach?