OB表索引大小问题

我现在想统计一下OB每张表的大小及其索引大小,目前统计索引大小使用的SQL如下(3节点):

select round(sum(h.required_size/3)/1024/1024,2) as index_size
from oceanbase.dba_ob_tablet_replicas h where h.tablet_id in(select DISTINCT(tablet_id)
from oceanbase.dba_ob_table_locations where data_table_id in (select DISTINCT(table_id)
from oceanbase.dba_ob_table_locations where table_name =’%s’ and role=‘LEADER’)
请问,这样统计是否有问题,或者是否还有更好的统计方法,求大佬们指导

select /*+ READ_CONSISTENCY(WEAK) */

dotl.database_name,

dotl2.table_name,

dotl.index_name,

concat(round(sum(dotr.data_size/1024/1024/1024), 2), ‘G’) datasize_primary_replica ,

concat(round(sum(dotr.required_size)/1024/1024/1024, 2), ‘G’) requiredsize_primary_replica

from

dba_ob_table_locations dotl,

dba_ob_tablet_replicas dotr,

dba_ob_table_locations dotl2

where dotl.ls_id = dotl2.ls_id

and dotl.svr_ip = dotl2.svr_ip

and dotl.role = dotl2.role

and dotl.data_table_id = dotl2.table_id

and dotl.ls_id = dotr.ls_id

and dotl.svr_ip = dotr.svr_ip

and dotl.tablet_id = dotr.tablet_id

and dotl.table_type = ‘INDEX’

and dotl.index_name = ‘idx_xxx’

and dotl.database_name = ‘db_xxx’

and dotl2.table_name = ‘tab_xxx’

and dotl.role = ‘leader’ --是否只查询主副本

group by dotl.index_name;

感觉和你的逻辑差不多,都是访问这些表,应该结果是一样的

但是你这个SQL好像有点查不动,差点把CPU干爆 :joy:

我这边好像没啥问题,有可能场景测试的不够充分,回头找找3-3-3的架构和分区表测试一下。