Read PG stat recovery
read_pg_stat_recoveryRetrieve standby recovery replay LSN, lag, last replayed timestamp, and startup state from PG 19's pg_stat_recovery view. Returns no rows on primary or older PG versions.
Instructions
Return rows from PG 19's pg_stat_recovery view — replay progress, lag, and startup state for a standby. Empty list on PG < 19, when the view isn't present, or when the server isn't in recovery (a primary running standalone returns no rows). Returns a list of objects with replay_lsn, replay_lag_seconds, last_replayed_at, and startup_state (any of which may be null when not applicable).
Example: read_pg_stat_recovery()
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 |
|---|---|---|---|
| result | Yes |