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 a Slow SQL Query
00:00
5 left

Optimize a Slow SQL Query

MediumSQL · PostgreSQL

Problem

Tell me about a time you had to optimize a slow-running SQL query or data pipeline at Boeing, and what steps you took to improve performance.

Using the provided Boeing maintenance tables, write the optimized PostgreSQL query you would use to summarize qualifying aircraft work. Address how you would validate the performance improvement.

Output

  1. One row per qualifying aircraft, with aircraft_id, aircraft_model, completed_work_orders, and total_labor_hours.
  2. Include completed work opened during 2025 with at least two work orders and associated maintenance events.
  3. Order by total_labor_hours descending, then aircraft_id ascending.

Schema

aircraft
ColumnTypeDescription
aircraft_idPKINTUnique aircraft identifier
aircraft_modelVARCHAR(50)Aircraft model designation
plant_codeVARCHAR(10)Manufacturing plant code
work_orders
ColumnTypeDescription
work_order_idPKINTUnique work-order identifier
aircraft_idINTAircraft associated with the work order
statusVARCHAR(20)Current work-order status
opened_atDATEDate the work order was opened
maintenance_events
ColumnTypeDescription
event_idPKINTUnique maintenance-event identifier
work_order_idINTWork order associated with the event
event_typeVARCHAR(30)Type of maintenance event
labor_hoursNUMERIC(8,2)Labor hours recorded for the event
Tablesaircraftwork_ordersmaintenance_events
Interviewer

Your question is Optimize a Slow SQL Query. 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.