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
Optimizing SQL and Data Pipelines
00:00
5 left

Optimizing SQL and Data Pipelines

MediumSQL · PostgreSQL

Problem

Tell me how you would optimize a slow-running SQL query or a memory-intensive data pipeline used in JPMorgan Chase data platforms.

Assume you are reviewing a PostgreSQL workload that joins query telemetry with pipeline run metadata. Write a SQL query that returns the worst-performing jobs by average runtime and memory usage, so an engineer can prioritize tuning work.

Output

  1. One row per job name.
  2. Columns: job_name, avg_runtime_ms, avg_peak_memory_mb, slow_run_count.
  3. Include only jobs with at least 2 runs and an average runtime above 1000 ms.
  4. Ignore rows where peak_memory_mb is NULL.
  5. Sort by avg_runtime_ms descending, then avg_peak_memory_mb descending, then job_name ascending.

Schema

jobs
ColumnTypeDescription
job_idPKINTUnique job identifier
job_nameVARCHAR(100)Human-readable job name
platformVARCHAR(50)JPMorgan Chase data platform name
pipeline_runs
ColumnTypeDescription
run_idPKINTUnique run identifier
job_idINTReferences jobs.job_id
run_dateDATEDate the run executed
runtime_msNUMERIC(12,2)Total runtime in milliseconds
peak_memory_mbNUMERIC(12,2)Peak memory usage in megabytes
Tablesjobspipeline_runs
Interviewer

Your question is Optimizing SQL and Data Pipelines. Start with the requirements and the two 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.