Search docs
Docs searchValidation rule
Back to Rule CatalogAP-DQR-006Data / Query RiskLarge collection loaded then processed in memory
Flags query flows that load broad collections and filter or aggregate them in memory.
warningviolationNo auto-fix
How to fix
- Push filtering, projection, and aggregation into the query.
- Apply limits before loading records.
- Move large exports to explicit batch workflows.
What it means
A workflow appears to fetch more rows than it needs before applying filtering or aggregation.
Why it matters
In-memory processing can degrade latency and memory use for large tenants or repositories.
Common causes
- Filtering was easier to express in application code.
- Pagination was applied after fetching all rows.
- A report path reused online request code.
Example bad pattern
findMany(...) loads all findings, then filters open findings in JavaScript.Example good pattern
findMany({ where: { status: 'open' }, take: pageSize }).Related files/config
apps/api/srcpackages/db/prisma/schema.prisma
Related CLI commands
archpilot validatearchpilot validate --ci
Related docs