Search docs

Docs search
Back to Rule Catalog
AP-DQR-008Data / Query Risk

Repeated query pattern in one request flow

Flags request flows that repeat the same or similar query multiple times.

warningviolationNo auto-fix

How to fix

  1. Fetch shared context once and pass it through.
  2. Batch similar queries.
  3. Add request-level caching only when it matches consistency needs.

What it means

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.

Example bad pattern

A request loads organization membership in auth, service, and repository helpers separately.

Example good pattern

Resolve membership once, then pass the scoped context through the workflow.

Related files/config

  • apps/api/src
  • packages/db/prisma/schema.prisma

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-DQR-008 - Repeated query pattern in one request flow | ArchPilot Docs