Count hidden assignment queries made by one inbox request
The main SQL query is quick, but the API loads the latest assignee separately for every visible work order.
- Focused work estimate
- 2h + prerequisites
- Priority in the scenario
- High
- Engineering practice
- N+1 diagnosis · ORM behavior
Estimated field mix
- Performance engineering40%
- Backend30%
- Database engineering30%
Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.
Review it, then add it to your workspace.
The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.
Project context
A fictional maintenance service lists open work orders beside years of closed history. A query that was cheap in a small demo now scans far more rows than it returns. Recreate the schema and synthetic workload locally; no customer database or supplied fixture is assumed.
Setup prerequisites
- Create an isolated local database with tenants, work orders and assignment history.
- Seed 200,000 synthetic work orders with documented skew and a repeatable random seed; record PostgreSQL version, settings and resource limits.
Preceding work
Complete these dependencies, or supply their agreed outputs before taking this ticket.
Acceptance criteria
- Record the query count for page sizes 1, 20 and 100 without storing raw tenant payloads in logs.
- Add a request-level assertion exposing query growth proportional to returned rows.
- Preserve assignment ordering, including equal timestamps and work orders with no history.
Implementation constraints
- Instrument the local database client boundary so lazy ORM loads are counted as well as explicit queries.
Verification to include
- Request all three page sizes and compare total database calls.
- Use a work order with multiple assignment records and verify the selected assignee matches the documented tie-breaker.
Deliverables
- Query-count regression and assignment fixture
Rollout and recovery
Enable detailed counting in the local investigation only; retain a bounded aggregate if instrumentation is later adapted for deployment.
Value of the work
For the engineer: Practice reading execution plans, balancing read and write cost, and validating performance without weakening tenant boundaries.
For the team: Create reproducible query diagnostics and reversible index or query proposals for an operational application.
Evidence boundaries
Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.
Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.