Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 3manuek/53e67f9cc926b1535e926c3b547b448c to your computer and use it in GitHub Desktop.
Save 3manuek/53e67f9cc926b1535e926c3b547b448c to your computer and use it in GitHub Desktop.
Calculate bytes per N seconds for estimating speed of restores
WITH timeset AS (
select pg_database_size(datname) num, pg_size_pretty(pg_database_size(datname)) size from pg_database where datname = 'db'
UNION ALL
select pg_database_size(datname) num, pg_size_pretty(pg_database_size(datname)) size from pg_database, pg_sleep(10) where datname = 'db'
)
SELECT num - lag(num,1) OVER (ORDER BY num) bytes_per_10_second, size FROM timeset
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment