# Queries need result bounds

Principle `queries-need-result-bounds`. Limit result cardinality before the driver materializes an oversized response.

Also searched as: unbounded result set, result cardinality.

A timeout can limit waiting while leaving a large result problem intact. Limit query results explicitly and choose a bounded consumption path.

Book basis: [B4](/bibliography#b4-release-it).

## Failure it prevents

One query exhausts memory despite a concurrency limit of one.

## Our Effect 4.0.5 reading

Stream.take bounds consumption of a real stream. It cannot undo a driver’s full allocation. Apply limits or cursor pagination in the query adapter.

Source: `packages/effect/src/Stream.ts`.

## How to check

Use a dataset larger than the intended result budget. Check rows fetched and memory before consumption completes. This is our proposed verification, not a quoted procedure.

Continue with [Steady state recycles resources](/principles/steady-state-recycles-resources), [Bulkheads isolate scarce capacity](/principles/bulkheads-isolate-capacity).

Connect this to [the existing rat-stack guidance](https://ratstack.sh/lore/concurrent-work-needs-an-owner).

Use [the durability skill](/skills/durability) for the full review. Return to [the durability index](/principles/durability).

## Skills
- [Durability starts with a recovery record](/principles/durability)

## Sources
- Nygard, Michael T. *Release It!: Design and Deploy Production-Ready Software*. Pragmatic Bookshelf, 2007. [Link](https://archive.org/details/releaseitdesignd0000nyga). ([b4-release-it](/bibliography#b4-release-it))

## References
- [Effect contributors. Effect 4.0.5. Stream.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/Stream.ts). Pinned source for our Effect mapping, not a claim from the book.
