云数据库 GAUSSDB(FOR MYSQL)-查看GaussDB(for MySQL)的存储容量:通过命令查看存储容量

时间:2024-07-15 10:42:45

通过命令查看存储容量

连接 GaussDB (for MySQL)数据库后,执行如下命令查看存储容量。

show spaceusage;

上述命令查询到的存储容量值等于表数据、表预分配空间、分区预分配空间、Binlog、Redolog和undo space之和,详情请参见表1

information_schema信息不是实时刷新的,查询之前可以先执行如下命令进行刷新:

set information_schema_stats_expiry = 0;

表1 存储容量说明

条目

查看方式

说明

表数据

select sum(data_length+index_length+data_free) from information_schema.tables;

传统MySQL的容量计算方式,该语句依赖统计数据的精准度,在统计数据未更新时可能会有偏差。

表预分配空间

select count(*) from information_schema.tables;

每张表会预分配4MB空间,该语句查询出表的数量乘以4MB就是总的表预分配空间。

分区预分配空间

select count(*) from INFORMATION_SCHEMA.PARTITIONS where PARTITION_NAME is not null;

每个分区会预分配4MB空间,该语句查询出分区的数量乘以4MB就是总的分区预分配空间。

Binlog

show binary logs;

将所有binlog的文件大小相加。

Redolog

show lsninfo;

flushed_to_disk_lsn- truncate_lsn

undo space

select sum(INITIAL_SIZE) as undo_space from information_schema.files where file_type='UNDO LOG ';

undo空间。

support.huaweicloud.com/trouble-gaussdbformysql/gaussdbformysql_trouble_0508.html