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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Optimize Query Performance
00:00
5 left

Optimize Query Performance

HardSQL · PostgreSQL

Problem

Tell me about how you optimize query performance for large-scale TaskRabbit data workloads.

Write an optimized PostgreSQL query against the supplied TaskRabbit tables that summarizes task workload by provider market, creation month, and task category. Include all tasks in the date range, including tasks without an assignment, and calculate completion metrics and month-over-month completed-task changes.

Output

  1. One row per market, month, and category whose category rank is at most 2 within that market and month.
  2. Columns: market, month_start, category, total_tasks, completed_tasks, completion_rate_pct, previous_completed_tasks, and category_rank.
  3. Sort by market, month_start, category_rank, and category ascending.

Schema

tasks
ColumnTypeDescription
task_idPKINTUnique TaskRabbit task identifier
created_atTIMESTAMPTimestamp when the task was created
categoryVARCHAR(80)Task service category
statusVARCHAR(30)Current task status
feeNUMERIC(10,2)Task fee in dollars
task_assignments
ColumnTypeDescription
task_idPKINTAssigned task identifier
provider_idINTTasker assigned to the task
assigned_atTIMESTAMPAssignment timestamp
providers
ColumnTypeDescription
provider_idPKINTUnique Tasker identifier
provider_nameVARCHAR(100)Tasker display name
marketVARCHAR(60)Provider operating market
provider_tierVARCHAR(30)Provider service tier
Tablestaskstask_assignmentsproviders
Interviewer

Your question is Optimize Query Performance. Start with the requirements and the three 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.