How would you optimize a slow-performing database query that is critical for real-time portfolio reporting?