oracle 效能最佳化操作四:盡量去掉"IN"、"OR",oracle效能最佳化

來源:互聯網
上載者:User

oracle 效能最佳化操作四:盡量去掉"IN"、"OR",oracle效能最佳化

含有"IN"、"OR"的Where子句常會使用工作表,使索引失效;

如果不產生大量重複值,可以考慮把子句拆開;拆開的子句中應該包含索引。  

例:    

select count(*) from stuff where id_no in('0','1');--(23秒)

可以考慮將or子句分開:  

select count(*) from stuff where id_no='0'; select count(*) from stuff where id_no='1';

然後再做一個簡單的加法,與原來的SQL語句相比,查詢速度更快。

相關文章

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.