zoukankan      html  css  js  c++  java
  • oracle之sql语句优化

    oracle之sql语句优化
    sql语句的优化

      1.在where子句中使用 is null 或 is not null 时,oracle优化器就不能使用索引了.



      2.对于有连接的列,即使最有一个是静态的值,优化器也不会使用索引 比如: select * from employss where first_name||''||last_name='Beill cliton' 要写成 :select * from employss where first_name='Beill' and last_name='Beill cliton' 这时oracle 就会采用 基于 last_name 的索引



      3.带通配符 (%) 的 like 语句 比如: select * from employee where last_name like '%cliton%'; %在词首出现oracle系统就不能使用 last_name 的索引; select * from employee where last_name like 'cliton%'



      4:order by 任何在order by语句的非索引项或者表达式都会降低查询效率;

      5:NOT $amp;<amp;$gt;是就相当于not p="" 当oracle”遇到”not,他就会停止使用索引转而执行全表扫描.<="" not会产生在和在索引列上使用函数相同的影响.="" ①和②的查询结果是一样的,但②允许oracle对salary列使用索引,效率高="" <3000="" salary="" or="" >3000="" from="" *="" select="" ②="" salary$amp;<amp;$gt;3000;="" ①="">

      6: exist 代替 in not exist 代替 not in select * from A where id in(select id from B) 以上查询使用了in语句,in()只执行一次,它查出B表中的所有id字段并缓存起来.之后,检查A表的id是否与B表中的 id相等,如果相等则将 A表的记录加入结果集中,直到遍历完A表的所有记录. exist 比 in 的执行效率更高


       

    7:
    551x364


    8.where条件的顺序

    576x348


    9:UNION ALL  和 UNION
    718x551

  • 相关阅读:
    OpenCV 3.4.0 + Visual Studio 2015开发环境的配置(Windows 10 X64)
    数值分析4
    数值分析3
    数值分析2
    数值分析1
    绪论0.4
    绪论0.3
    绪论0.2
    绪论0.1
    GitHub之起势
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/4701601.html
Copyright © 2011-2022 走看看