升级到oceanbase 4.2.1之后系统表变化导致工具无法使用

【 使用环境 】生产环境
【 OB or 其他组件 】OB
【 使用版本 】V4.2.1
【问题描述】在社区版V3.1.4的时候,我们使用自己写的工具通过以下SQL查询单表、分区表以及二级分区表的行数
sql=“select A.part_name, B.part_id, B.total_row_count from (select (partition_id >> 32)&0x0FFFFFFF as part_id,sum(row_count) AS total_row_count from oceanbase.gv$partition where table_id={0} and role = 1 group by part_id order by part_id) B, __all_part A where A.part_id=B.part_id and A.table_id=({0}&(~(-1<<40)))”.format(full_table_id)

sql=“select A.part_name, B.part_id, B.total_row_count from (select (partition_id) as part_id,sum(row_count) AS total_row_count from oceanbase.gv$partition where table_id={0} and role = 1 group by part_id order by part_id) B, __all_part A where A.part_id=B.part_id and A.table_id=({0}&(~(-1<<40)))”.format(full_table_id)

sql=‘select “N/A” as part_name, partition_id, row_count from gv$partition where table_id={0} and role=1’.format(full_table_id)

升级之后,GV$系列的表已经不存在,也找不到哪张系统表统计了分区及表的行数,如何解决?

1 个赞

3.X 跟4.X版本的视图相差太大了。自己写工具得写两套。

差距看这个:
https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000001050034

2 个赞

gv$partition是__all_table,__all_meta_table,__all_root_table join的视图,如果想保持和3.x查询的方式 你就使用这个三个基表替换 4.x的视图变化比较大