Search docs
Docs searchValidation rule
Back to Rule CatalogAP-DQR-008Data / Query RiskRepeated query pattern in one request flow
Flags request flows that repeat the same or similar query multiple times.
warningviolationNo auto-fix
How to fix
- Fetch shared context once and pass it through.
- Batch similar queries.
- Add request-level caching only when it matches consistency needs.
What the rule validates
A workflow appears to execute duplicate query patterns during one request.
Why it matters
Repeated queries add latency and increase load without improving correctness.
Common causes
- Several helpers independently fetch the same record.
- No request-level memoization or shared query result exists.
- A service calls multiple workflows that each reload context.
Typical violation example
A request loads organization membership in auth, service, and repository helpers separately.Typical compliant example
Resolve membership once, then pass the scoped context through the workflow.Related rules
AP-DQR-001 - Missing tenant filter evidence in multi-tenant SQLAP-DQR-002 - Broad SELECT * usage in query pathAP-DQR-003 - Unbounded query risk without limit/pagination evidenceAP-DQR-004 - Cross-module direct database access bypasses module boundary
Adjacent categories
Related files/config
apps/api/srcpackages/db/prisma/schema.prisma
Related CLI commands
archpilot validatearchpilot validate --ci