yupDB等价两种查询方式及性能对比

// 1、第一种查询方式
select substr(time,1,6) as time count(id) as con,src_system_type as srcSystemType from(
select id,time,src_system_type from test_table where yup_partitions like 'test_table_%' 
and time >='20200106000000'
and time <='20210106000000'
)t group by substr(time,1,6),src_system_type 
// 2、第二种查询方式
with cr1 as (select id,time,src_system_type  from test_table where yup_partitions like 'test_table_%' 
and time >='20200106000000'
and time <='20210106000000'),cr2 as (select substr(cr1.time,1,6)as time,cr1.id,cr1.src_system_type from  cr1)select cr2.time,count(cr2.id)as con,src_system_type as srcSystemType from cr2 group by cr2.time,cr2.src_system_type  
  1. 上述两种查询方式均是完成同一个功能,即按照时间单位为月来进行统计各个src_system_type的数据总量。
  2. 上述两种查询性能对比:第一种查询方式是按照传统的查询方式来进行查询,第二种查询方式是yupDB数据库特有的查询方式,采用的策略是建立中间表的方式来处理。当查询条件少时,且对于统计数据这个功能来讲时,第一种查询方式占优(亲测);当查询条件比较复杂时,个人感觉第二种方式比较合理。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值