Query Complexity Guard
Component Detail
Infrastructure
medium complexity
backend
0
Dependencies
2
Dependents
0
Entities
0
Integrations
Description
Enforces query complexity limits to protect PostgreSQL performance under concurrent reporting load. Validates the number of requested joins, the maximum result row count, and the breadth of GROUP BY dimensions before a query is executed. Returns structured errors with user-friendly messaging when limits are exceeded.
query-complexity-guard
Responsibilities
- Count the number of required table joins in a query plan
- Verify requested result set size does not exceed the configured row limit
- Reject specifications with too many simultaneous GROUP BY dimensions
- Return typed complexity violation errors with remediation hints
Interfaces
checkComplexity(spec)
getJoinCount(spec)
getEstimatedRowCount(spec, orgId)
validateGroupByDepth(groupings[])
getComplexityLimits()
formatViolationError(violation)
Relationships
Dependents (2)
Components that depend on this component