hot_standby_feedback can prevent PostgreSQL reporting queries from being canceled when vacuum cleanup conflicts with WAL replay, but it does so by delaying dead-row cleanup on the primary—which can cause table bloat. It is a targeted trade-off, not a way to prevent every standby cancellation. Whether to enable it depends on how your workload weighs completed reports against replica freshness, failover readiness, and primary-side storage.
Why PostgreSQL cancels queries on a reporting replica
The primary does not wait for standby queries before making and recording changes. The standby must replay those changes from write-ahead log (WAL), and a WAL record can conflict with a query running against the standby. For example, vacuum cleanup may remove a row version that a standby query’s snapshot could still need, or affect a page the query is accessing. PostgreSQL can delay replay for a configured period; if the conflict remains, it cancels the query so replay can proceed. PostgreSQL’s hot-standby documentation describes these conflicts and the available delay behavior.
As an Amazon Associate I earn from qualifying purchases.
Vacuum cleanup is a common cause, but not the only one. Primary-side DDL that needs an access-exclusive lock, dropping a database, or dropping a tablespace can also conflict with standby activity. Vacuum can also produce visibility-map conflicts affecting index-only scans, even when no old row versions need cleanup. The PostgreSQL documentation lists these conflict types.
What hot_standby_feedback changes
Set hot_standby_feedback on the standby. When enabled, the standby sends information about queries in progress to its upstream server so that cleanup does not remove row versions those queries may need. In cascading replication, feedback is forwarded upstream. PostgreSQL 18 documents the setting as off by default, and says feedback is sent no more frequently than the configured wal_receiver_status_interval. Confirm the documentation for your deployed major version before relying on that default. PostgreSQL 18 replication settings
#1 Best Overall
The benefit is specific: feedback can prevent cancellations caused by cleanup records. The cost is that cleanup of dead rows can be delayed on the primary, which may cause bloat for some workloads. It does not prevent cancellations caused by DDL or every other conflicting WAL action. The PostgreSQL 18 parameter reference describes this trade-off.
How replay-delay settings differ
max_standby_streaming_delay controls how long a standby may delay applying streamed WAL before canceling conflicting queries. PostgreSQL 18 documents a default of 30 seconds; -1 permits indefinite waiting. This is an allowance for applying WAL received from the primary, not a separate maximum runtime for each query. If earlier replay work has already used the allowance, a later conflicting query may have less time.
Rank #2
For WAL read from an archive, the corresponding setting is max_standby_archive_delay, also documented with a 30-second default in PostgreSQL 18. These are version-specific documented defaults, not universal recommendations. Check the reference for the PostgreSQL major version you run before changing settings. PostgreSQL 18 replication settings
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Longer delay settings can give long-running decision-support queries more time, but WAL replay stalls while the conflict is being tolerated. Other standby sessions may consequently see older data. For a standby whose main purpose is high availability, PostgreSQL advises relatively short delay settings so query-related stalls do not let the standby fall far behind. Hot-standby documentation
Rank #3
Choose based on reports, freshness, and primary cleanup
There is no universally correct setting. Assess the role of this specific standby and the cost of each failure mode:
- Report completion: How disruptive are canceled reports? Can clients safely retry them, or do cancellations interrupt work that is expensive to restart?
- Freshness and recovery: How stale can reporting data become while replay waits? Does the standby also need to remain ready for high availability?
- Primary cleanup and storage: Can the primary tolerate delayed removal of dead row versions? How will operators detect whether table bloat is increasing?
If cleanup-related cancellations are the dominant problem and the primary can tolerate delayed cleanup, test hot_standby_feedback and monitor primary table behavior. If freshness or failover readiness matters more, keep replay delays appropriately constrained and accept or reduce exposure to long-running conflicts. If reports need more time, tune the relevant streaming or archive delay with the understanding that it slows replay; it does not grant every query its own runtime allowance. PostgreSQL’s hot-standby guidance recommends shorter delays for high-availability standbys.
Monitor cancellations alongside lag and table growth
On the standby, inspect pg_stat_database_conflicts for cancellation counts and conflict reasons. PostgreSQL also identifies pg_stat_database as a source of summary information. Evaluate a configuration change by correlating changes in standby conflicts with replica replay freshness and primary-side table growth; fewer cancellations alone do not show whether the overall trade-off is acceptable. PostgreSQL monitoring statistics
Recommended Free Tools
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




