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
Partitioning and Query Performance
00:00
5 left

Partitioning and Query Performance

MediumSQL · PostgreSQL

Problem

Explain the concept of data partitioning and how it impacts query performance.

Demonstrate the explanation with a PostgreSQL query that retrieves project costs for the first quarter of 2025. The date predicate should allow a range-partitioned cost table to exclude irrelevant partitions.

Output

  1. One row per office included in the filtered data
  2. Columns: office_name, total_cost
  3. Include only costs from January 1 through March 31, 2025
  4. Order by total_cost descending, then office_name ascending with null office names last

Schema

project_costs
ColumnTypeDescription
cost_idPKINTUnique cost record identifier
office_idINTOffice associated with the cost
cost_dateDATECost date and range-partitioning key
amountDECIMAL(12,2)Recorded project cost
offices
ColumnTypeDescription
office_idPKINTUnique office identifier
office_nameVARCHAR(100)Display name of the office
regionVARCHAR(50)Geographic region
Tablesproject_costsoffices
Interviewer

Your question is Partitioning and Query Performance. 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.