Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
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
Sign up free to run your codeLog inLn 1
Run your query to see results here.