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 Sharding at Scale
00:00
5 left

Partitioning and Sharding at Scale

HardSQL · PostgreSQL

Problem

Describe your experience with data partitioning and sharding strategies in large-scale databases.

Using the supplied shard metadata and event records, produce a distribution report that highlights uneven shard utilization. Treat events without an assigned shard as excluded from shard percentages.

Output

  1. One row per configured shard, including shards with no events.
  2. Columns: shard_id, shard_name, event_count, distinct_users, event_share_pct, and distribution_status.
  3. Order by event_count descending, then shard_id ascending. Label shards above 40% as overloaded, below 10% as underutilized, and all others as balanced.

Schema

shards
ColumnTypeDescription
shard_idPKINTUnique identifier for a database shard
shard_nameVARCHAR(100)Readable shard name
regionVARCHAR(50)Deployment region for the shard
pin_events
ColumnTypeDescription
event_idPKINTUnique event identifier
shard_idINTAssigned database shard
user_idINTUser associated with the event
event_typeVARCHAR(50)Type of recorded event
event_dateDATEDate when the event occurred
Tablesshardspin_events
Interviewer

Your question is Partitioning and Sharding at Scale. 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.