首批通过分布式安全可靠测评,为关键业务系统打造
如何查看索引表占用磁盘空间的大小
更新时间:2026-05-22 08:56
OceanBase 数据库如何查询索引表占用的磁盘空间。
OceanBase 数据库 V4.x 之前版本。
确定主表和索引表的 table_id。
__all_table表中包含所有的索引表和基表。## -- 查询租户下 user_name 表的所有索引的 table_id 和索引名。 select table_id, table_name from __all_table where data_table_id = (select table_id from __all_table where table_name = 'user_name');从
__all_virtual_storage_stat表中查询索引表所占用的磁盘空间, 表中used_size列表示索引表使用的 SSTable 的大小。select used_size/1024/1024/1024 as used_gb from __all_virtual_storage_stat where sstable_id = 'your_index_table_id' and table_id = 'your_base_table_id' and svr_ip = 'your_server_ip' and major_version = 'current_major_version'注意
__all_virtual_storage_stat表中 size 相关大小在合并后更新。
OceanBase 数据库 V4.x 之后版本。
根据主表的 table_id 查找索引表的 id。
select table_id, table_name from __all_table where tenant_id = 'your_tenant_id' and data_table_id = 'your_base_table_id';根据 table_id 确定主表和索引表的 tablet_id。
select tablet_id from __all_virtual_tablet_to_table_history where table_id = 'your_index_table_id';根据 tablet_id 找到对应的表/索引表占用磁盘空间的大小。
select required_size/1024/1024/1024 as size_gb from __all_virtual_tablet_meta_table where tenant_id = 'your_tenant_id' and tablet_id = 'index_table_tablet_id';注意
__all_virtual_tablet_meta_table表的 size 相关列在合并后更新。
适用版本
OceanBase 数据库所有版本。