Partitioning
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 7 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    How big is one month of the UPI-style payments table?

      What does a DELETE of the oldest month cost?

        Build-up · 6 steps

        Inside a partitioned table

        The parent stores nothing. Partition bounds route every write, prune every read, and turn retention into dropping a table.

        Step 1 of 6

        One parent, no storage

        Your SQL names upi_txn, declared PARTITION BY RANGE (created_at). The parent holds no rows of its own; it knows only its partitions and their bounds.

        4 interview moments

        You’re the candidate

        The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

        1. Deep dive 1 of 4

          Interviewer

          “Your one primary can’t keep up with inserts at peak. A teammate proposes partitioning the payments table by month. What do you say?”

          Your move. Pick an approach:

        2. Deep dive 2 of 4

          Interviewer

          “Compliance says keep 13 months of payments. How do you remove the oldest month, 300 million rows, every month?”

          Your move. Pick an approach:

        3. Deep dive 3 of 4

          Interviewer

          “You range-partition payments by created_at, 300 million rows a month, 13 months kept. Daily, weekly or monthly partitions?”

          Some frequent lookups arrive by txn_id alone, with no date.

          Your move. Pick an approach:

        4. Deep dive 4 of 4

          Interviewer

          “Your partitioned payments table’s key is (txn_id, created_at). A retried payment gets a fresh now(). How do you stop a duplicate?”

          Your move. Pick an approach: