Skip to content

Instantly share code, notes, and snippets.

@dialogbox
Created July 13, 2016 08:48
Show Gist options
  • Save dialogbox/17acde133798c76a3e5cde15f28d600c to your computer and use it in GitHub Desktop.
Save dialogbox/17acde133798c76a3e5cde15f28d600c to your computer and use it in GitHub Desktop.
Query for monitoring wal log population.
DO $$
DECLARE
cur pg_lsn;
cur2 pg_lsn;
BEGIN
cur := pg_current_xlog_location();
loop
execute pg_sleep(5);
cur2 := pg_current_xlog_location();
RAISE NOTICE '% : %/s', to_char(clock_timestamp(), 'YYYY/MM/DD HH24:MI:SS'), pg_size_pretty(pg_xlog_location_diff(cur2, cur)/5);
cur := cur2;
end loop;
END
$$ ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment