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?
Asked
Active
Viewed 2.6k times
18
-
You can see it by running a query (on the slave). – x-yuri Jan 26 '21 at 23:32
2 Answers
27
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)

wsn
- 1,097
- 8
- 15
-
2Well, actually I want to know does standby server executes sql queries. For example, on master I can run `SELECT datname, query FROM pg_stat_activity ;` and see what live queries are there. On slave/standby I can only see current query (from pg_stat_activity) – Feb 23 '15 at 22:18
-
1If I execute a read-only query on the master server, is it automatically dispatched to the slave server? – Darion Badlydone Jun 26 '18 at 07:44
-
4@DarionBadlydone No, you need to route your read-only query to slave server, by configuring your application or by using proxy software. – wsn Jul 22 '18 at 09:02
0
You can see simply with linux top
command with pressing c
. For example it is a process from our standby site top
command list
postgres: pgUserNameSeen pgDatabaseName 10.10.10.10 (56608) idle
if you do not see anything like that, your standby does not server for read-only
queries.

ridonekorkmaz
- 21
- 2