ORACLE-017:SQL优化-is not null和nvl
2017-06-03 09:10
627 查看
今天在优化一段sql,原脚本大致例如以下:
select a.字段n from tab_a a where a.字段2 is not null;
a.字段2添加了索引的,可是查询速度很慢。
于是做了例如以下改动:
select a.字段n from tab_a a where nvl(a.字段2,'0' ) != '0';
速度提升非常明显。
原因是什么呢?事实上非常easy,由于is null和is not null使字段的索引失效了。
尽管都知道哪些情形下会使索引失效,可是有时难免受业务需求的影响而考虑的不够全面,所以sql优化要时刻进行。随时进行。努力提高sql的运行效率。
相关文章推荐
- ORACLE-017:SQL优化-is not null和nvl
- ORACLE-017:SQL优化-is not null和nvl
- Oracle SQL中IS NOT NULL与!=NULL的区别
- oracle 性能优化操作六: 去掉Where子句中的IS NULL和IS NOT NULL
- Oracle SQL中IS NOT NULL与!=NULL的区别
- oracle 性能优化操作六: 去掉Where子句中的IS NULL和IS NOT NULL
- sql语句查询时is not null 的使用
- oracle is null 和is not null
- Oracle sql"NOT IN"语句优化,查询A表有、B表没有的数据
- SQL中IS NOT NULL与!=NULL是等价的吗
- Ibatis中的动态SQL:isNotNull,isPropertyAvailable,isNotEmpty用法
- Oracle SQL NULL 值对 IN/NOT IN语句的影响
- SQL IS NOT NULL条件走索引 试验
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- Oracle sql"NOT IN"语句优化,查询A表有、B表没有的数据
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect to this MySQL server"
- Oracle Bug: WARNING:Could not lower the asynch I/O limit to 224 for SQL direct I/O. It is set to -1
- 远程mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- 远程mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect