Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 884
Alexander Avatar asked Feb 20 '15 17:02

Alexander


People also ask

How do I know if PostgreSQL is read-only?

The output of SELECT pg_is_in_recovery() can tell you if the cluster is in the read-only mode.

What is the difference between hot standby and cold standby?

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.

What is hot standby server?

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.

What is Hot_standby in Postgres?

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.


1 Answers

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)
like image 123
yoloseem Avatar answered Sep 23 '22 00:09

yoloseem