【索引】反向索引--條件 範圍查詢(二)
當 where 條件中 含有 <> 條件或者 not in 時 走INDEX FAST FULL SCAN 執行計劃中的 限制條件 not in 轉換為 <>
where 條件中含有 = 號 或in 時 走INDEX RANGE SCAN 注意執行計劃中的限制條件 in 被轉換為 =PHP code:
SQL> select object_id from t1 where object_id <> 1;
53519 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 711836071
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 53518 | 261K| 29 (4)| 00:00:01 |
|* 1 | INDEX FAST FULL SCAN| I_ID | 53518 | 261K| 29 (4)| 00:00:01 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"<>1)
Statistics
----------------------------------------------------------
1 recursive calls
。。。。。。
53519 rows processed
SQL> select object_id from t1 where object_id not in (45,65,95,32,1,2,5,64,83);
53511 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 711836071
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 53510 | 261K| 31 (10)| 00:00:01 |
|* 1 | INDEX FAST FULL SCAN| I_ID | 53510 | 261K| 31 (10)| 00:00:01 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"<>45 AND "OBJECT_ID"<>65 AND "OBJECT_ID"<>95
AND "OBJECT_ID"<>32 AND "OBJECT_ID"<>64 AND "OBJECT_ID"<>83 AND
"OBJECT_ID"<>5 AND "OBJECT_ID"<>2 AND "OBJECT_ID"<>1)
PHP code:
SQL> select object_id from t1 where object_id =55 or object_id =65;
Execution Plan
----------------------------------------------------------
Plan hash value: 3991740069
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 10 | 3 (0)| 00:00:01 |
| 1 | INLIST ITERATOR | | | | | |
|* 2 | INDEX RANGE SCAN| I_ID | 2 | 10 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=55 OR "OBJECT_ID"=65)
Statistics
----------------------------------------------------------
1 recursive calls
。。。。。。
2 row
PHP code:
SQL> select object_id from t1 where object_id in (45,65,95,32,1,2,5,64,83);
8 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 3991740069
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 9 | 45 | 9 (0)| 00:00:01 |
| 1 | INLIST ITERATOR | | | | | |
|* 2 | INDEX RANGE SCAN| I_ID | 9 | 45 | 9 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=1 OR "OBJECT_ID"=2 OR "OBJECT_ID"=5 OR
"OBJECT_ID"=32 OR "OBJECT_ID"=45 OR "OBJECT_ID"=64 OR "OBJECT_ID"=65 OR
"OBJECT_ID"=83 OR "OBJECT_ID"=95)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-672908/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 關於聯合索引,範圍查詢,時間列索引的幾個問題索引
- MYSQL DQL in 到底會不會走索引&in 範圍查詢引發的思考。MySql索引
- MySQL 唯一索引範圍查詢鎖下一個記錄的理解MySql索引
- AppBoxFuture: 二級索引及索引掃描查詢資料APP索引
- MySQL實驗: 實踐索引對全列匹配、最左字首匹配、範圍查詢等條件的影響以及瞭解髒讀、幻讀等MySql索引
- Elasticsearch(三):索引查詢Elasticsearch索引
- elasticsearch之多索引查詢Elasticsearch索引
- ElasticSearch分片互動過程(建立索引、刪除索引、查詢索引)Elasticsearch索引
- [20180926]查詢相似索引.txt索引
- MongoDB慢查詢與索引MongoDB索引
- 【原創】MySQL 模擬條件索引MySql索引
- mysql條件查詢MySql
- MongoDB查詢條件MongoDB
- 根據某個查詢條件的前50條資料來決定UPDATE語句的更新範圍
- MySQL索引與查詢優化MySql索引優化
- IndexPatternService 模糊查詢索引 fuzzyQuery分析Index索引
- oracle之 反向鍵索引Oracle索引
- 反向索引處理前%索引
- PostgreSQL多查詢條件,多個索引的選擇演算法與問題診斷方法SQL索引演算法
- Oracle日期時間範圍查詢Oracle
- Laravel 多條件查詢Laravel
- 為什麼所有的查詢條件都命中索引還是那麼慢?記一次慢查詢優化過程索引優化
- MySQL 覆蓋索引、回表查詢MySql索引
- indexedDB 通過索引查詢資料Index索引
- 資料庫聚簇索引——not null條件對唯一鍵索引成為聚簇索引的影響資料庫索引Null
- 為什麼所有的查詢條件都命中索引還是那麼慢?記一次慢查詢最佳化過程索引
- 理解索引(中):MySQL查詢過程和高階查詢索引MySql
- SpringBoot Jpa多條件查詢Spring Boot
- AntDesignBlazor示例——列表查詢條件Blazor
- golang beego orm 查詢條件 or andGolangORM
- Javaweb-DQL-條件查詢JavaWeb
- 查詢條件封裝物件封裝物件
- mongodb條件查詢不等於MongoDB
- 【mybatis-plus】條件查詢MyBatis
- PostgreSQLjson索引實踐-檢索(存在、包含、等值、範圍等)加速SQLJSON索引
- Oracle 條件索引 case when 報錯解決方案Oracle索引
- 一個查詢不走索引的例子索引
- MySQL 學習之索引篇和查詢MySql索引
- MySQL 索引及查詢優化總結MySql索引優化