Как посмотреть размер баз и таблиц?
# du -hsx /var/lib/pgsql 178G /var/lib/pgsql
SELECT pg_database_size('имя базы');
SELECT pg_database_size('oid');
# psql -U postgres -A -c "select pg_database_size('имя базы')"
SELECT pg_database_size(current_database());
mbillcz5054=# SELECT pg_database_size(current_database()) AS size_Bytes, pg_database_size(current_database())/1024.0/1024/1024 AS size_GBytes, pg_size_pretty(pg_database_size(current_database())) AS size_pretty; size_bytes | size_gbytes | size_pretty --------------+----------------------+------------- 189442111248 | 176.4317147880792617 | 176 GB
SELECT sum(pg_database_size(datname)) FROM pg_database;
SELECT pg_relation_size('имя таблицы');
# psql -U postgres имя базы -c "SELECT pg_relation_size('имя таблицы')"
SELECT pg_relation_size('prices') AS size_Bytes,
pg_relation_size('prices')/1024.0/1024/1024 AS size_GBytes,
pg_size_pretty(pg_relation_size('prices')) AS size_pretty;
size_bytes | size_gbytes | size_pretty
------------+--------------------+-------------
3834396672 | 3.5710601806640625 | 3657 MB
SELECT pg_total_relation_size('имя таблицы');
SELECT pg_total_relation_size('prices') AS size_Bytes,
pg_relation_size('prices')/1024.0/1024/1024 AS size_GBytes,
pg_size_pretty(pg_relation_size('prices')) AS size_pretty;
# \dt+ prices
List of relations
Schema | Name | Type | Owner | Size | Description
--------+--------+-------+----------+---------+-------------
public | prices | table | postgres | 3657 MB |
select pg_column_size('имя столбца') from 'имя таблицы';