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 Slow BigQuery Queries
00:00
5 left

Optimizing Slow BigQuery Queries

MediumSQL · PostgreSQL

Problem

Walk me through your process for optimizing a slow-running query in BigQuery.

For the hands-on portion, use the supplied PostgreSQL tables and produce the optimized result query. Discuss how you would inspect the execution plan, reduce scanned rows, validate correctness, and confirm an improvement.

Output

  1. One row per active query and run date, with query_name, owner_team, run_date, run_count, avg_duration_ms, and total_bytes_processed.
  2. Include only successful runs from January 2026 whose duration is at least 1,000 milliseconds, ordered by query_name, then run_date.

Schema

query_runs
ColumnTypeDescription
run_idPKINTUnique query execution identifier
query_idINTReferenced query definition
started_atTIMESTAMPExecution start timestamp
duration_msINTExecution duration in milliseconds
bytes_processedBIGINTBytes processed by the execution
statusVARCHAR(20)Execution status
query_catalog
ColumnTypeDescription
query_idPKINTUnique query definition identifier
query_nameVARCHAR(100)Human-readable query name
owner_teamVARCHAR(80)Team responsible for the query
is_activeBOOLEANWhether the query definition is active
Tablesquery_runsquery_catalog
Interviewer

Your question is Optimizing Slow BigQuery Queries. 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.