in_list查詢與or擴充套件
select t.COMPANY_ID, t.GMT_CREATE, t.GMT_MODIFIED, t.PRODUCT_ID
from t
where (t.PRODUCT_ID) in
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50)
from t
where (t.PRODUCT_ID) in
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50)
在沒有統計資訊的情況下,9I會走or擴充套件,rule規則產生的執行計劃。這種執行計劃的效率沒有IN_LIST查詢高,而且執行計劃會非常的長。佔用比較大的共享池。
如果想走 in_list查詢,可以嘗試如下幾種辦法:
1)收集統計資訊,那麼就會採用CBO去產生執行計劃,CBO會有限選擇IN_LIST查詢
2)增加HINT,增加有效的HINT後,也會打破RULE規則,而去使用CBO去產生執行計劃。有如下兩個HINT可以參考:
select /*+ index(t index_name) */
t.COMPANY_ID, t.GMT_CREATE, t.GMT_MODIFIED, t.PRODUCT_ID
from t
where (t.PRODUCT_ID) in
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50);
t.COMPANY_ID, t.GMT_CREATE, t.GMT_MODIFIED, t.PRODUCT_ID
from t
where (t.PRODUCT_ID) in
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50);
select /*+ NO_EXPAND */ t.COMPANY_ID, t.GMT_CREATE, t.GMT_MODIFIED, t.PRODUCT_ID
from t
where (t.PRODUCT_ID) in
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50);
from t
where (t.PRODUCT_ID) in
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50);
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-712965/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 並查集擴充套件並查集套件
- Linq查詢語法與擴充方法
- Lambda擴充套件與用途套件
- BSGS與擴充套件BSGS套件
- Oracle 12CR2查詢轉換之表擴充套件Oracle套件
- Mybatis之map操作使用者和模糊查詢擴充套件MyBatis套件
- 在EF Core 中使用AsQueryable擴充套件方法的拼接查詢套件
- 並查集擴充套件應用並查集套件
- kotlin 擴充套件(擴充套件函式和擴充套件屬性)Kotlin套件函式
- PHP 擴充套件 Mongo 與 MongoDBPHP套件MongoDB
- PHP 擴充套件 Mysql 與 MysqliPHP套件MySql
- 查詢表空間是否具備自動擴充套件空間套件
- Solon詳解(六)- Solon的校驗擴充套件框架使用與擴充套件套件框架
- WCF擴充套件:行為擴充套件Behavior Extension套件
- CSS——讓這些“展示”有更好的擴充套件性——媒體查詢CSS套件
- PHPWAMP安裝Redis擴充套件的方式與相關擴充套件的下載PHPRedis套件
- 【Kotlin】擴充套件屬性、擴充套件函式Kotlin套件函式
- 檢查PHP擴充套件是否安裝成功PHP套件
- Sanic 擴充套件套件
- ORACLE 擴充套件Oracle套件
- 擴充套件工具套件
- 擴充套件歐幾里得套件
- DOM擴充套件套件
- 擴充套件ACL套件
- Lua擴充套件套件
- 照片擴充套件套件
- 擴充套件篇套件
- disable or 擴充套件套件
- 擴充套件表套件
- Mybatis擴充套件MyBatis套件
- js陣列擴充套件用lamada表示式實現查詢是否存在JS陣列套件
- JMeter 擴充套件開發:擴充套件 TCP 取樣器JMeter套件TCP
- POJ 1733 Parity【擴充套件域並查集】套件並查集
- HDU 3234 Exclusive-OR 擴充套件並查集套件並查集
- Laravel MongoDB 資料庫查詢擴充外掛 擴充原始 Laravel 類LaravelMongoDB資料庫
- ?用Chrome擴充套件管理器, 管理你的擴充套件Chrome套件
- ASP.NET Core擴充套件庫之Http通用擴充套件ASP.NET套件HTTP
- php7安裝redis擴充套件和memcache擴充套件PHPRedis套件