gbase8a获取大表数据SQL语句

项目背景
从gbase8a迁移数据到mysql5.6.46中,获取大表记录数

生成查询某个schema下所有表的记录数的SQL语句
select concat(‘select ‘’’,table_schema,’.’,table_name,’’’ as table_name,count() as total_num from ‘,table_name,’ union all’) from information_schema.tables where table_schema=‘test’;
结果如下
select ‘test.cmst_i_h_data’ as table_name,count(
) as total_num from cmst_i_h_data union all
select ‘test.info_config’ as table_name,count() as total_num from info_config union all
select ‘test.m_page_view_log’ as table_name,count(
) as total_num from m_page_view_log union all
select ‘test.sync_table’ as table_name,count() as total_num from sync_table union all
select ‘test.test’ as table_name,count(
) as total_num from test union all
select ‘test.test1’ as table_name,count() as total_num from test1 union all
select ‘test.test_100’ as table_name,count(
) as total_num from test_100 union all
去掉最后一行的union all部分,并将查询放入下面查询结构体中
select table_name,total_num from (
上述查询语句
) as t
where total_num>1000000

说明: total_num>1000000代表查询某个schema下超过1百万记录的表

总结:
1、获取大表记录数也有其他方式,只要有相应权限即可
2、count()不加条件,速度一样非常快,8a采用express存储引擎,这里怀疑表记录总数是单独存储的
gbase> select count(
) from test_100;
±---------+
| count(*) |
±---------+
| 9463294 |
±---------+
1 row in set (Elapsed: 00:00:00.00)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值