---
title: "Keep reports and exports off the primary · Agent Wranglers"
url: https://agentwranglers.se/playbook/scaling/growing-the-database/reports-off-primary
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Keep reports and exports off the primary

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Growing the database](https://agentwranglers.se/playbook/scaling/growing-the-database.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- ID: SCL-24
- Level: Recommended
- Chapter: [Growing the database](https://agentwranglers.se/playbook/scaling/growing-the-database)
- Rule: Run long reads, such as reports, exports and analytics, on a replica or a separate copy. The primary serves the app's own reads and writes.
- How: A report that scans a large table pushes the app's hot rows out of memory and holds a connection for minutes. Give reports their own database role and a connection address that points to a replica, with a longer [query time limit](https://agentwranglers.se/playbook/data/operations/query-timeouts) of their own. On a PostgreSQL standby, replay cancels a conflicting query once `max_standby_streaming_delay` has passed. Raise that delay on a reporting replica, never on the one kept for failover. Which reads may lag is set by [Read from replicas only what may lag](https://agentwranglers.se/playbook/data/caches-and-copies/replica-lag).
- Check: The reporting role can connect only to the replica host. The 20 queries with the most total time on the primary include no report or export query.

## Sources

- [PostgreSQL hot standby](https://www.postgresql.org/docs/current/hot-standby.html)

## Related rules

- [Set time limits on every query](https://agentwranglers.se/playbook/data/operations/query-timeouts) in Data
- [Read from replicas only what may lag](https://agentwranglers.se/playbook/data/caches-and-copies/replica-lag) in Data

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/scaling/growing-the-database/reports-off-primary">Agent Wranglers scaling playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Fit the connection budget to the autoscaling maximum](https://agentwranglers.se/playbook/scaling/growing-the-database/connection-budget)
- Next: [Partition tables that outgrow memory](https://agentwranglers.se/playbook/scaling/growing-the-database/partition-large-tables)
- [Growing the database](https://agentwranglers.se/playbook/scaling/growing-the-database)
