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
Optimizing Skewed Massive Datasets
00:00
5 left

Optimizing Skewed Massive Datasets

HardSQL · PostgreSQL

Problem

How do you handle and optimize queries that involve massive datasets with highly skewed distribution keys at Twilio?

Write a PostgreSQL query that returns monthly delivered-message metrics for eligible Twilio Messaging tenants during Q1 2026. The query should remain correct when one tenant owns a disproportionately large share of events.

Output

  1. One row per eligible tenant and month, with tenant_id, account_name, plan_name, month_start, delivered_messages, and average_latency_ms.
  2. Include active, non-test tenants with delivered message events in the period. Sort by month_start, then tenant_id.

Schema

messaging_events
ColumnTypeDescription
event_idPKBIGINTUnique messaging event identifier
tenant_idVARCHAR(40)Tenant that generated the event
occurred_atTIMESTAMPTZEvent timestamp
event_typeVARCHAR(30)Type of messaging event
delivery_statusVARCHAR(20)Delivery outcome
latency_msINTEGERDelivery latency in milliseconds
twilio_tenants
ColumnTypeDescription
tenant_idPKVARCHAR(40)Twilio customer tenant identifier
account_nameVARCHAR(100)Customer account name
regionVARCHAR(20)Primary customer region
plan_idVARCHAR(30)Messaging plan reference
statusVARCHAR(20)Tenant lifecycle status
is_testBOOLEANWhether the tenant is a test account
messaging_plans
ColumnTypeDescription
plan_idPKVARCHAR(30)Messaging plan identifier
plan_nameVARCHAR(60)Human-readable plan name
Tablesmessaging_eventstwilio_tenantsmessaging_plans
Interviewer

Your question is Optimizing Skewed Massive Datasets. 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.