perf(db): add missing indexes, fix N+1 batch delete, add pagination limits

- Add indexes on Resource(blueprintId, roleId), DemandRequirement(roleId),
  Assignment(roleId) — commonly filtered FK columns that were missing indexes
- Replace N+1 batch delete pattern (2N queries) with findAllocationEntries()
  that does 2 total queries via findMany({ id: { in: ids } })
- Add take/skip pagination with default limit of 500 to listDemands and
  listAssignments to prevent unbounded result sets

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-11 08:09:39 +02:00
parent 110e4ff1aa
commit c098cedf06
7 changed files with 264 additions and 158 deletions
+1
View File
@@ -50,6 +50,7 @@ export {
export {
findAllocationEntry,
findAllocationEntries,
loadAllocationEntry,
type AllocationEntryResolution,
} from "./use-cases/allocation/load-allocation-entry.js";