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 endpoint of a small orders service scales its query count with result size and is missing an index its access path needs. Find the offending query pattern among several efficient neighbors and make the request issue a bounded number of queries. A query counter in the harness enforces the bound.

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 the current folder and starts the solve clock.

    promptly init stage-1-05-orm-n-plus-1-fix
  3. Start the captured session

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

    promptly start stage-1-05-orm-n-plus-1-fix
  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.

promptly play stage-1-05-orm-n-plus-1-fix