Postgresql – How to check if hot standby serves read-only queries

database-replicationpostgresql

I have setup replication: master – slave. Slave server works as hot-standby, which means we can run read-only sql queries.
How actually can I see that slave server is serving read-only queries?

Best Answer

You can use pg_is_in_recovery() which returns True if recovery is still in progress(so the server is running in standby mode). Check the System Administration Functions for further informations.

=# SELECT pg_is_in_recovery();
 pg_is_in_recovery
───────────────────
 f
(1 row)
Related Topic