Batch latest-assignee lookup for the current inbox page
Fetching one assignee per work order makes latency increase with page size even after the main inbox query is tuned.
- Focused work estimate
- 3h 30m + prerequisites
- Priority in the scenario
- High
- Engineering practice
- Query design · Tenant isolation
Estimated field mix
- Database engineering50%
- Backend30%
- Performance engineering20%
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
- Resolve assignments in a bounded number of queries independent of page size up to 100.
- Preserve tenant scope in every lookup and return one deterministic latest assignment per visible work order.
- Return identical response data to the baseline fixture, including missing assignments.
Implementation constraints
- Compare a batched lookup and a lateral or window-query alternative; record the chosen tradeoff using the seeded distribution.
Verification to include
- Compare complete responses and query counts for page sizes 1, 20 and 100.
- Inject a foreign-tenant assignment ID into the request fixture and verify it cannot be returned.
Deliverables
- Batched implementation, response equivalence tests and query-count results
Rollout and recovery
Switch the lookup path independently; revert to the previous implementation if equivalence or tenant checks fail.
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.