暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

使用系统表查询GBase 8a数据库表空间占用

原创 GBASE数据库 2025-03-28
341

原文链接:https://www.gbase.cn/community/post/5565
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。

通过系统表查看表占用磁盘空间大小

   可以通过 information_schema.cluster_tables 表的 TABLE_DATA_SIZE 和TABLE_STORAGE_SIZE字段进行统计,具体统计方法如下:
   TABLE_DATA_SIZE 是数据存储空间(主备分片之和)
   TABLE_STORAGE_SIZE 是数据存储空间+元数据存储空间(主备分片之和)
   
   以本地虚拟机2节点集群 p 2 d 1 配置为例,创建hash分布表test:

   CREATE TABLE "test" ("a" int(11) DEFAULT NULL) DISTRIBUTED BY('a'); 插入数据并翻倍到83886080条记录。
   
   gbase> select TABLE_NAME,TABLE_DATA_SIZE,TABLE_STORAGE_SIZE from information_schema.cluster_tables where table_schema='lz' and table_name='test';
   +------------+-----------------+--------------------+
   | TABLE_NAME | TABLE_DATA_SIZE | TABLE_STORAGE_SIZE |
   +------------+-----------------+--------------------+
   | test       |         1571972 |            1846824 |
   +------------+-----------------+--------------------+

1)TABLE_DATA_SIZE 计算   

[gbase@node1 test_n2]$ pwd
/opt/gnode/userdata/gbase/lz/sys_tablespace/test_n2
[gbase@node1 test_n1]$ du -csb *
104428 C00000.seg
209177 C00000.seg.1
313605 total
[gbase@node1 test_n1]$ cd ../test_n2/
[gbase@node1 test_n2]$ du -csb *
157454 C00000.seg
314927 C00000.seg.1
472381 total

(313605+472381)*2=1571972(TABLE_DATA_SIZE

2)TABLE_STORAGE_SIZE 计算
再计算元数据空间

[gbase@node1 test_n1.GED]$ pwd
/opt/gnode/userdata/gbase/lz/metadata/test_n1.GED
[gbase@node1 test_n1.GED]$ du -csb *
128 C00000.ctl.A
128 C00000.ctl.B
54325 C00000.map
230 table.des.A
230 table.des.B
52 table.state.A
52 table.state.B
55145 total
[gbase@node1 test_n1.GED]$ cd ../test_n2.GED/
[gbase@node1 test_n2.GED]$ du -csb *
128 C00000.ctl.A
128 C00000.ctl.B
81461 C00000.map
230 table.des.A
230 table.des.B
52 table.state.A
52 table.state.B
82281 total

(55145 + 82281)*2 + 1571972(TABLE_DATA_SIZE=1846824 (TABLE_STORAGE_SIZE

原文链接:https://www.gbase.cn/community/post/5565
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论