【 使用环境 】生产环境 or 测试环境
【 OB or 其他组件 】OB
【 使用版本 】V3.1.5 社区版、V3.2.3企业版
【问题描述】以下sql查询库表数据量是否准确?是否所有用户均可执行?
select
table_name,
table_rows,
avg_row_length,
data_length,
index_length
from
information_schema.tables
where
table_schema = ‘test’
– and table_name = ‘t1’
;
可以查看这个信息
SELECT sum(size)/1024/1024/1024 FROM (SELECT DATABASE_NAME,TABLE_NAME,TABLE_ID,PARTITION_NAME,TABLET_ID,ROLE
FROM oceanbase.DBA_OB_TABLE_LOCATIONS ) AA full join
(SELECT distinct(TABLET_ID) ,size
FROM oceanbase.GV$OB_SSTABLES ) BB on AA.TABLET_ID=BB.TABLET_ID
WHERE AA.role=‘leader’ and AA.table_name=’${表名}’;
这里面是统计信息采集时候的数据量吧
统计信息不是准确的数据量,准确的数据量应该用count查
统计信息数据量不准确
这个看上去像是V4的库表吧
是的,估值
是的,巡检不要求精确,估值即可
information.tables的信息不一定准确
知道了,谢谢
是的 如果是v3的话 可以使用这个语句试一下
OB 2.2.x/3.x 版本
SELECT /*+ READ_CONSISTENCY(WEAK) QUERY_TIMEOUT(50000000) */ tenant_id, svr_ip, svr_port, table_id, partition_id, data_size, required_size, row_count,0 AS data_table_id from (SELECT tenant_id, svr_ip, svr_port, table_id, partition_id, data_size, required_size, row_count FROM __all_virtual_meta_table union SELECT tenant_id, svr_ip, svr_port, table_id, partition_id, data_size, required_size, row_count FROM __all_root_table);