-
Notifications
You must be signed in to change notification settings - Fork 4
MyTopling information_schema
rockeet edited this page Nov 8, 2024
·
3 revisions
information_schema 中存储了 MyTopling 的元数据。
全局字典(gdic)需要全部加载进内存,从这个意义上,全局字典更象 index。
全局字典(gdic)又属于数据而非索引,从这个意义上,全局字典又非 index。
所以,根据需要,可以将全局字典计入索引或数据。
TAG 是 MVCC 元数据,在 SST 文件内部独立分离存储,单独计算,应当归入索引。
# index 压缩后的总尺寸,不包含全局字典
select sum(INDEX_BLOCK_SIZE + TAG_SIZE) as zip_index_size from ROCKSDB_SST_PROPS;
# index 压缩后的总尺寸,包含全局字典
select sum(INDEX_BLOCK_SIZE + TAG_SIZE + GDIC_SIZE) as zip_index_size from ROCKSDB_SST_PROPS;
# index 原始数据的总尺寸
select sum(RAW_KEY_SIZE) as index_raw_size from ROCKSDB_SST_PROPS;
# index 总的压缩率(压缩前/压缩后)
select sum(RAW_KEY_SIZE)/sum(INDEX_BLOCK_SIZE + TAG_SIZE) as index_zip_xxx from ROCKSDB_SST_PROPS;
# index 总的压缩率(压缩后/压缩前)
select sum(INDEX_BLOCK_SIZE + TAG_SIZE)/sum(RAW_KEY_SIZE) as index_zip_ratio from ROCKSDB_SST_PROPS;
# 数据压缩后的总尺寸,不包含全局字典
select sum(DATA_BLOCK_SIZE) as zip_data_size from ROCKSDB_SST_PROPS;
# 数据压缩后的总尺寸,包含全局字典
select sum(DATA_BLOCK_SIZE + GDIC_SIZE) as zip_data_size from ROCKSDB_SST_PROPS;
# 数据解压后的总尺寸
select sum(RAW_VALUE_SIZE) as raw_data_size from ROCKSDB_SST_PROPS;
# 数据总的压缩率(压缩前/压缩后)
select sum(RAW_VALUE_SIZE)/sum(DATA_BLOCK_SIZE + GDIC_SIZE) as data_zip_xxx from ROCKSDB_SST_PROPS;
# 数据总的压缩率(压缩后/压缩前)
select sum(DATA_BLOCK_SIZE + GDIC_SIZE)/sum(RAW_VALUE_SIZE) as data_zip_ratio from ROCKSDB_SST_PROPS;
# 数据和索引压缩后的总尺寸,包含全局字典
select sum(INDEX_BLOCK_SIZE + DATA_BLOCK_SIZE + TAG_SIZE + GDIC_SIZE) as zip_size from ROCKSDB_SST_PROPS;
# 数据和索引解压后的总尺寸
select sum(RAW_KEY_SIZE + RAW_VALUE_SIZE) as raw_size from ROCKSDB_SST_PROPS;
# 数据总的压缩率(压缩前/压缩后)
select sum(RAW_KEY_SIZE + RAW_VALUE_SIZE)/sum(INDEX_BLOCK_SIZE + DATA_BLOCK_SIZE + TAG_SIZE + GDIC_SIZE) as zip_xxx from ROCKSDB_SST_PROPS;
# 数据总的压缩率(压缩后/压缩前)
select sum(INDEX_BLOCK_SIZE + DATA_BLOCK_SIZE + TAG_SIZE + GDIC_SIZE)/sum(RAW_KEY_SIZE + RAW_VALUE_SIZE) as zip_ratio from ROCKSDB_SST_PROPS;
# 要获得更完整的信息,需要:
# 连接 ROCKSDB_DDL, ROCKSDB_INDEX_FILE_MAP, ROCKSDB_SST_PROPS
select *
from ROCKSDB_DDL
join ROCKSDB_INDEX_FILE_MAP
on ROCKSDB_INDEX_FILE_MAP.INDEX_NUMBER = ROCKSDB_DDL.INDEX_NUMBER
join ROCKSDB_SST_PROPS
on ROCKSDB_SST_PROPS.SST_NAME = ROCKSDB_INDEX_FILE_MAP.SST_NAME;
以上述 SQL 语句为蓝本,进行更具体的查询,例如:
select *
from ROCKSDB_DDL
join ROCKSDB_INDEX_FILE_MAP
on ROCKSDB_INDEX_FILE_MAP.INDEX_NUMBER = ROCKSDB_DDL.INDEX_NUMBER
join ROCKSDB_SST_PROPS
on ROCKSDB_SST_PROPS.SST_NAME = ROCKSDB_INDEX_FILE_MAP.SST_NAME
where TABLE_NAME = "bmsql_oorder"; -- 仅查看该表,包含该表的二级索引
可以结合(二)统计特定表的索引与数据尺寸。