Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: 能否提供TABLEDUMP功能 #109

Closed
xuji755 opened this issue Mar 5, 2024 · 7 comments
Closed

[Feature]: 能否提供TABLEDUMP功能 #109

xuji755 opened this issue Mar 5, 2024 · 7 comments
Assignees
Labels
Milestone

Comments

@xuji755
Copy link

xuji755 commented Mar 5, 2024

Describe your use case

提供TABLEDUMP功能

Describe the solution you'd like

在TABLEDUMP中,将表的建表脚本,表数据分布情况(在不同OBSERVER上的分片数量,数据容量),是否存在倾斜,是否存在空洞等做详细的DUMP

Describe alternatives you've considered

No response

Additional context

No response

@Teingi
Copy link
Contributor

Teingi commented Mar 11, 2024

obdiag gather scene 是按照yaml方式编排的信息采集场景,obdiag gather scene list 可以列出支持的套餐。
参考文档:https://open.oceanbase.com/blog/9965179152

TABLEDUMP 这个功能可以非常小成本的在obdiag中实现,添加一个yaml(相当于增加了一个场景),比如:

obdiag gather scene run --scene=observer.table_dumper--env "{db_connect='-hxx -Pxx -uxx -pxx -Dxx', table_name='xx'}"

表的建表脚本,表数据分布情况(在不同OBSERVER上的分片数量,数据容量),是否存在倾斜,是否存在空洞等通过定义好的yaml文件按照sql来查询就行。

@Teingi Teingi added this to the v2.1.0 milestone Mar 28, 2024
@Teingi Teingi added the enhancement New feature or request label Mar 28, 2024
@duzp111
Copy link
Contributor

duzp111 commented Apr 1, 2024

1

@Teingi
Copy link
Contributor

Teingi commented Apr 7, 2024

4月7号沟通:按照基础场景来定义

@Teingi
Copy link
Contributor

Teingi commented May 5, 2024

移动到2.2.0迭代

@Teingi Teingi modified the milestones: v2.1.0, v2.2.0 May 5, 2024
@wayyoungboy wayyoungboy modified the milestones: v2.2.0, v2.3.0 May 31, 2024
@Teingi
Copy link
Contributor

Teingi commented Jun 27, 2024

-- ob >= 4.0 查询table_id
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */ 
t.table_id from oceanbase.__all_virtual_table t where t.tenant_id = ? and t.database_id = ? and table_name = ? limit 1;

-- ob < 4.0 查询表数据大小,行数
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */ 
m.svr_ip,
m.role,
m.data_size total_data_size, 
m.row_count as total_rows_count
from oceanbase.__all_virtual_meta_table m, oceanbase.__all_virtual_table t 
where m.table_id = t.table_id and m.tenant_id = ? and m.table_id = ? and t.table_name = ? order by total_rows_count desc limit 1


-- ob >= 4.0 查询表数据大小
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */ 
t1.svr_ip,
t1.role,
ifnull(t2.data_size,0) as total_data_size 
from (select tenant_id, database_name, role, table_id, tablet_id 
from oceanbase.cdb_ob_table_locations) t1 left join 
(select tenant_id, tablet_id,
data_size from oceanbase.cdb_ob_tablet_replicas) 
t2 on t1.tenant_id = t2.tenant_id and 
t1.tablet_id = t2.tablet_id where  t1.tenant_id = ? and t1.table_id = ? order by total_data_size desc limit 1;

-- ob >= 4.0 查询表数行数
select /*+read_consistency(weak) QUERY_TIMEOUT(60000000) */ 
ifnull(num_rows,0) from cdb_tables where con_id = ? and owner = ? and table_name = ? order by num_rows desc limit 1;

@Teingi
Copy link
Contributor

Teingi commented Jul 1, 2024

database_id查看:
ob >=4.0版本

SELECT con_id as tenant_id, object_id as database_id, object_name as database_name FROM  oceanbase.cdb_objects where OBJECT_TYPE = 'DATABASE' and con_id = ?

ob<4.0版本

select tenant_id,database_id,database_name from gv$database where tenant_name = ? and database_name = ?

This was referenced Jul 5, 2024
@Teingi
Copy link
Contributor

Teingi commented Jul 9, 2024

PR #311

@Teingi Teingi closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants