oracle之sql語句最佳化

來源:互聯網
上載者:User

標籤:

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:



8.where條件的順序




9:UNION ALL  和 UNION

oracle之sql語句最佳化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.