Created
October 24, 2023 03:36
-
-
Save hungtcs/415095102bdb66c4bd734773dc2eeb51 to your computer and use it in GitHub Desktop.
Postgres 数据库、schema、table 大小获取方式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 数据库大小 | |
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