We have a query that powers a critical TaskRabbit dashboard but is timing out; walk me through the steps you would take to optimize its performance.
Use the supplied schema as a representative dashboard workload. Provide an optimized PostgreSQL query and explain how you would validate that it is faster while preserving the dashboard results.
Output
- One row per qualifying task category, with columns
category_name, completed_tasks, gross_revenue, avg_rating, and category_rank.
- Include completed Brooklyn tasks from January 1 through January 31, 2025, handled by active taskers.
- Sort by
category_rank, then category_name ascending.