建议7.19 - 建议7.21

建议7.19:用case语句合并多次表扫描

select count ( case when column1 < 1000 then 1 else null end ),
       count ( case when column1 between 1000 and 5000 then 1 else null end), 
       count ( case when column1 > 5000 then 1 else null end)
from t_tablename;

建议7.20:慎用distinctunionorder bygroup by语句,因为这些语句会引起排序,在无法消除排序的情况下尽量不要使用。

建议7.21:当使用索引产生的逻辑I/O远远大于表扫描时,应该屏蔽索引,如果字段为数值型的就在表达式后面“+ 0”,为字符型的就并上一个“空串”。

--数值型屏蔽索引
select column
  from t_tablename
 where column_num + 0 > 30;
 
--字符型屏蔽索引
select column
  from t_tablename
 where column_char || '' = 'ABC';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值