Recommend read your writes
recommend_read_your_writesChecks PostgreSQL server role and replication lag to recommend using WAIT FOR LSN for read-your-writes consistency, ensuring up-to-date reads from standbys.
Instructions
Advise whether the caller should use WAIT FOR LSN for read-your-writes consistency. Combines server role (primary vs standby), replay lag, and PG version into a structured recommendation. Never raises. reason is one of primary_no_wait_needed, standby_no_lag, standby_lag_unknown, standby_with_lag, standby_pg18_or_older, unavailable. Returns an object with recommend_use (bool), reason, is_in_recovery, server_version_num, current_lag_bytes (int / null), and detail.
Example: recommend_read_your_writes()
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detail | Yes | ||
| reason | Yes | ||
| recommend_use | Yes | ||
| is_in_recovery | Yes | ||
| current_lag_bytes | Yes | ||
| server_version_num | Yes |