限制索引

一、不等於操作符(<>、!=)

表customers表的cust_rating列有一個索引,但下面的查詢語句仍然全表掃描

select cust_id,cust_name from customers where cust_rating <> 'aa';

將上面語句改成如下查詢語句,採用基於規則的優化器時,會使用索。

select cust_id,cust_name from customers where cust_rating<'aa' or cust_rating >'aa';

二、IS NULL或IS NOT NULL

三、使用函數

  select * from emp where trunc(hsdate)='01-sep-10';

上面的語句就不會使用索引,下列語句會使用索引

select * from emp where hsdate<(to_date('01-sep-10')+0.9999);

四、比較不匹配的數據類型

account_number varchar2(18);

select * from banks where account_number = 123456

oracle會自動把where子句改成:to_number(account_number)=123456;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章