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


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 Solution

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();
(1 row)
Related Question