← Nextdoor Interview Insights

Nextdoor·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Nextdoor analytics engineering interview, SQL-heavy round focused on building idempotent ETL pipelines on top of rollup tables. The question was a continuation of an earlier dashboard design problem, so if you haven't thought through the schema beforehand you're already behind.

Questions Asked (1)

Q1

Given raw tables for users, sessions, photos, likes, comments, and follows, write idempotent SQL ETL queries that compute and upsert KPIs (user growth, DAU, photo activity, and follower distribution including median and p90) into rollup tables for a target date parameter.

Data ModelingProduct Analytics & MetricsSystem Design
Author's notes

This one took me a while to even parse.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and KPI definitions, then design each KPI query as an idempotent INSERT ... ON CONFLICT DO UPDATE into a rollup table keyed by date. Use CTEs to compute daily aggregates from raw tables, and handle follower distribution percentiles with window functions or percentile_cont, ensuring the target date parameter is applied consistently.

Pro tip: Mention that idempotency can be achieved by making the rollup table's primary key (date, metric) and using upserts, and that you'd wrap the ETL in a transaction to avoid partial updates. Also, consider using a staging table or MERGE for complex distributions to simplify reruns.

1. Clarify requirements and schema

Confirm the definitions of each KPI (e.g., user growth = new users per day, DAU = distinct active users per day), the grain of rollup tables, and the exact columns in raw tables. Ask about edge cases like time zones and late-arriving data.

2. Design rollup table schemas

Define rollup tables with a composite primary key (e.g., date, metric_name) to enable idempotent upserts. Include columns for the metric value and any dimensions (e.g., follower bucket).

3. Write idempotent KPI queries

For each KPI, write a query that computes the daily aggregate for the target date using CTEs, then uses INSERT ... ON CONFLICT DO UPDATE to upsert into the rollup table. For follower distribution, compute median and p90 using percentile_cont or window functions.

4. Ensure idempotency and transaction safety

Wrap all upserts in a single transaction so that reruns either fully succeed or roll back. Use DELETE+INSERT or MERGE if the rollup table has multiple rows per date (e.g., follower buckets).

5. Validate and test

Test the queries with sample data, including rerunning for the same date to confirm no duplicates. Check performance and consider indexing strategies for large tables.

Key Points to Mention

  • Idempotency via primary key on (date, metric) and INSERT ... ON CONFLICT DO UPDATE
  • Using CTEs to modularize complex aggregations and improve readability
  • Computing percentiles with percentile_cont (PostgreSQL) or window functions like PERCENT_RANK
  • Handling follower distribution: define buckets or compute exact median/p90 per user
  • Transaction wrapping to ensure atomicity and avoid partial updates
  • Parameterizing the target date to allow backfilling and reruns

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.