S01 · The Bootsector · L-05

ORM N+1 Fix

Difficulty
easy
Type
debugging
Session
Quick
Stack
Python python3.11
Domain
Database
Est. solve
~20 min

01 · The task

One route in a small orders service gets dramatically chattier with the database as its result set grows, while its neighbors stay lean. Work out what makes that endpoint's data access blow up with size and bring it back down to a flat, predictable cost.

02 · Constraints

  • No N+1 queries

    The endpoint must issue a bounded number of queries.

03 · Skills exercised

ormObject-relational mapping — and avoiding its N+1 query trap.query-optimizationReducing query count and cost, e.g. eager-loading to kill an N+1.indexingAdding the right database index so queries stay bounded.

How to playDaemon

The whole level runs through the local promptly daemon — it pulls the workspace, captures your token usage, tests locally, and submits the ranked run.

  1. Pair this machine

    One-time — approve the code under your devices.

    promptly pair
  2. Pull the workspace

    Downloads the starter kit into nplus1/ and starts the solve clock — cd in before the next step.

    promptly init nplus1
  3. Start the captured session

    Then drive your AI tool — the daemon meters every prompt and token live.

    promptly start
  4. Submit for ranked grading

    Runs the full hidden suite and ends the attempt.

    promptly submit

Or combine steps 02–03 into one commandShortcut

promptly play pulls the workspace, launches the daemon, and starts the captured session in a single step — the same as running init then start. Then cd nplus1 and drive your harness.

promptly play nplus1