Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Optimize Dashboard Query Performance
00:00
5 left

Optimize Dashboard Query Performance

MediumSQL · PostgreSQL

Problem

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

  1. One row per qualifying task category, with columns category_name, completed_tasks, gross_revenue, avg_rating, and category_rank.
  2. Include completed Brooklyn tasks from January 1 through January 31, 2025, handled by active taskers.
  3. Sort by category_rank, then category_name ascending.

Schema

tasks
ColumnTypeDescription
task_idPKINTUnique task identifier
tasker_idINTTasker assigned to the task
category_idINTTask category
cityVARCHAR(80)Task location city
statusVARCHAR(30)Task lifecycle status
completed_atDATEDate the task was completed
priceNUMERIC(10,2)Task price in dollars
taskers
ColumnTypeDescription
tasker_idPKINTUnique tasker identifier
display_nameVARCHAR(120)Tasker display name
is_activeBOOLEANWhether the tasker is currently active
signup_dateDATETasker signup date
categories
ColumnTypeDescription
category_idPKINTUnique category identifier
category_nameVARCHAR(100)Task category name
task_reviews
ColumnTypeDescription
review_idPKINTUnique review identifier
task_idINTReviewed task
ratingINTRating from one to five
Tablestaskstaskerscategoriestask_reviews
Interviewer

Your question is Optimize Dashboard Query Performance. Start with the requirements and the four tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.