Skip to content

Instantly share code, notes, and snippets.

@almog-barel
Last active July 28, 2023 09:36
Show Gist options
  • Select an option

  • Save almog-barel/af21dea9654872f920c29ff87076ee14 to your computer and use it in GitHub Desktop.

Select an option

Save almog-barel/af21dea9654872f920c29ff87076ee14 to your computer and use it in GitHub Desktop.
postgres get replication status
select case WHEN EXISTS (SELECT * FROM pg_stat_replication) THEN (SELECT CASE WHEN state = 'streaming' THEN true ELSE false END FROM pg_stat_replication LIMIT 1) WHEN pg_is_in_recovery() THEN (SELECT CASE WHEN status = 'streaming' THEN true ELSE false END FROM pg_stat_wal_receiver LIMIT 1) ELSE true END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment