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?
The output of SELECT pg_is_in_recovery() can tell you if the cluster is in the read-only mode.
Techopedia Explains Cold Standby Thereafter, it's employed only when updating noncritical data, which is done infrequently, or on failure of the primary system. In contrast, a hot standby system is running simultaneously with another identical primary system.
Hot Standby is the term used to describe the ability to connect to the server and run read-only queries while the server is in archive recovery or standby mode. This is useful both for replication purposes and for restoring a backup to a desired state with great precision.
In Hot Standby mode, the system employs two or more servers: A primary server runs the active database. This database accepts connections from clients and permits read-write operations. One or more standby servers run a copy of the active database.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With