PgBeam Docs

Query Budgets

Cap queries per window and rows per result for an agent credential. Runaway loops and full-table scans hit a ceiling instead of your database.

A budget caps how much an agent can run. You set queries per window, a maximum number of rows per result, and a statement timeout. When an agent loops or asks for too much, the budget stops it at the wire instead of letting it hammer your database.

Set a budget

Budget on a policy
pgbeam policies create analytics \
  --budget 5000/day \
  --max-rows 1000 \
  --statement-timeout 10s

In the dashboard, set the budget on the policy profile under Budgets.

What you can cap

LimitEffect
Queries per windowCap statements per hour or per day. The next query past the cap is blocked with an error until the window resets.
Max rowsTruncate any result to at most this many rows.
Statement timeoutCancel a statement that runs longer than this.

What the agent sees

A query past the cap comes back as a Postgres error (SQLSTATE 53400):

ERROR:  PgBeam agent day query budget exhausted; resets at 2026-06-15T00:00:00Z; ask your operator to raise the limit

The message names the window and the exact reset time, so an agent can back off rather than retry blindly. A per-day egress (bytes) budget produces a similar message when exceeded.

Per-region windows

Budget counters are kept per data plane and per region, like the rate limiter. An agent connects to one region in practice, so the window it sees is consistent. The control plane aggregates usage across regions and can trip the kill-switch if an organization-level ceiling is breached.

On this page