Skip to content

Instantly share code, notes, and snippets.

@artemrogov
Created May 27, 2019 06:23
Show Gist options
  • Save artemrogov/00ac5e77152e2abd79f0d33c16764c6f to your computer and use it in GitHub Desktop.
Save artemrogov/00ac5e77152e2abd79f0d33c16764c6f to your computer and use it in GitHub Desktop.
размер БД и таблицы БД в понятном человеческом виде
SELECT pg_size_pretty( pg_database_size( 'sample_db' ) );
pg_size_pretty
----------------
36 GB
Таким же макаром можно посмотреть и размер таблицы (с индексами)
SELECT pg_size_pretty( pg_total_relation_size( 'table' ) );
pg_size_pretty
----------------
6341 MB
Если нужно без индексов, тогда запрос другой:
# SELECT pg_size_pretty( pg_relation_size( 'table' ) );
pg_size_pretty
----------------
1341 MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment