How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?
You can use pg_is_in_recovery() which returns True if recovery is still in progress(so the server is running in standby mode or slave)
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)
If Return false so the server is running in primary mode or masterpostgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
f
(1 row)
No comments