Skip to content

Instantly share code, notes, and snippets.

@hungtcs
Created October 24, 2023 03:36
Show Gist options
  • Save hungtcs/415095102bdb66c4bd734773dc2eeb51 to your computer and use it in GitHub Desktop.
Save hungtcs/415095102bdb66c4bd734773dc2eeb51 to your computer and use it in GitHub Desktop.
Postgres 数据库、schema、table 大小获取方式
-- 数据库大小
select pg_size_pretty(pg_database_size(current_database()));
-- 只计算table size
select schemaname, pg_size_pretty(sum(pg_relation_size(schemaname || '.' || tablename))) from pg_tables group by schemaname;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment