关键字
kingbaseES,数据库大小,表大小
1、查看单个数据库的大小
使用ksql连接到数据库,使用sys_database_size函数
- kapp=# select sys_database_size('kapp');
- sys_database_size
- -------------------
- 1685672055
- (1 行记录)
- kapp=# select sys_size_pretty(sys_database_size('kapp'));
- sys_size_pretty
- -----------------
- 1608 MB
- (1 行记录)
2、查看所有数据库的大小,并按大小排序
- kapp=# select sys_database.datname, sys_database_size(sys_database.datname) as size from sys_database order by size desc;
- datname | size
- -----------+------------
- kapp | 1685672055
- test | 1284485239
- kdef | 18952311
- kou | 16601207
- samples | 15573507
- template2 | 12878339
- security | 12870147
- template0 | 12845571
- template1 | 12845571
- (9 行记录)
3、查看单个表的大小,并带单位输出
- kapp=# select sys_size_pretty(sys_relation_size('art_att_dat'));
- sys_size_pretty
- -----------------
- 24 kB
- (1 行记录)
4、查看所有表大小
- kapp=# select schemaname,relname,sys_size_pretty(sys_total_relation_size(relid)) from sys_stat_user_tables where schemaname='kapp' order by sys_relation_size(relid) desc limit 5;
- schemaname | relname | sys_size_pretty
- ------------+----------------------+-----------------
- kapp | log_data | 582 MB
- kapp | log_info | 384 MB
- kapp | form_freq_opinion | 69 MB
- kapp | wf_acl_entry | 1600 kB
- kapp | wf_his_step | 1144 kB
- (5 行记录)