GreenPlum查看表和数据库大小
表大小
zwcdb=# select pg_size_pretty(pg_relation_size('gp_test'));
pg_size_pretty
----------------
1761 MB
(1 row)
表和索引
zwcdb=# select pg_size_pretty(pg_total_relation_size('gp_test'));
pg_size_pretty
----------------
2186 MB
查看指定数据库
zwcdb=# select pg_size_pretty(pg_database_size('zwcdb'));
pg_size_pretty
----------------
2241 MB
所有数据库
zwcdb=# select datname,pg_size_pretty(pg_database_size(datname)) from pg_database;
datname | pg_size_pretty
-----------+----------------
zwcdb | 2241 MB
postgres | 47 MB
template1 | 47 MB
template0 | 45 MB
gpperfmon | 67 MB
(5 rows)
查看数据分布情况和磁盘空间
zwcdb=# select gp_segment_id,count(*) from gp_test group by gp_segment_id order by 1;
gp_segment_id | count
---------------+---------
0 | 5000000
1 | 4999999
2 | 5000001
3 | 5000000
(4 rows)
zwcdb=# select dfhostname, dfspace,dfdevice from gp_toolkit.gp_disk_free order by dfhostname;
dfhostname | dfspace | dfdevice
------------+----------+------------
sdw1 | 12273372 | /dev/sdb1
sdw1 | 12273372 | /dev/sdb1
sdw2 | 12273404 | /dev/sdb1
sdw2 | 12273404 | /dev/sdb1