[20180509]函式索引問題.txt
[20180509]函式索引問題.txt
--//重複測試:
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
create table t1 as
select
rownum id,
dbms_random.value(0,500) n1,
rpad('x',10) small_vc,
rpad('x',100) padding
from
all_objects
where
rownum <= 3000
;
create index t1_i1 on t1(id, trunc(n1));
2.測試:
SCOTT@book> set autotrace traceonly explain
SCOTT@book> select /*+ rule */ small_vc from t1 where id = 55 and trunc(n1) between 1 and 10 ;
Execution Plan
----------------------------------------------------------
Plan hash value: 3617692013
----------------------------------
| Id | Operation | Name |
----------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | TABLE ACCESS FULL| T1 |
----------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TRUNC("N1")<=10 AND TRUNC("N1")>=1 AND "ID"=55)
Note
-----
- rule based optimizer used (consider using cbo)
SCOTT@book> set autotrace off
--//並沒有出現作者的情況在11.2.0.4版本.
3.換一種方式:
SCOTT@book> Select /*+ rule */ small_vc from t1 where id = 55 and trunc(n1) between 1 and 10 ;
no rows selected
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID avqjpb1yh1pq4, child number 0
-------------------------------------
Select /*+ rule */ small_vc from t1 where id = 55 and trunc(n1) between 1 and 10
Plan hash value: 3617692013
----------------------------------
| Id | Operation | Name |
----------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | TABLE ACCESS FULL| T1 |
----------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / T1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter((TRUNC("N1")<=10 AND TRUNC("N1")>=1 AND "ID"=55))
Note
-----
- rule based optimizer used (consider using cbo)
- Warning: basic plan statistics not available. These are only collected when:
* hint 'gather_plan_statistics' is used for the statement or
* parameter 'statistics_level' is set to 'ALL', at session or system level
--//在11.2.0.3測試依舊全表掃描
4.換1個版本測試:
SCOTT@test> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx 10.2.0.4.0 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
create table t1 as
select
rownum id,
dbms_random.value(0,500) n1,
rpad('x',10) small_vc,
rpad('x',100) padding
from
all_objects
where
rownum <= 3000
;
create index t1_i1 on t1(id, trunc(n1));
SCOTT@test> Select /*+ rule */ small_vc from t1 where id = 55 and trunc(n1) between 1 and 10 ;
no rows selected
SCOTT@test> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID avqjpb1yh1pq4, child number 0
-------------------------------------
Select /*+ rule */ small_vc from t1 where id = 55 and trunc(n1) between
1 and 10
Plan hash value: 1429545322
---------------------------------------------
| Id | Operation | Name |
---------------------------------------------
|* 1 | TABLE ACCESS BY INDEX ROWID| T1 |
|* 2 | INDEX RANGE SCAN | T1_I1 |
---------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / T1@SEL$1
2 - SEL$1 / T1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter((TRUNC("N1")<=10 AND TRUNC("N1")>=1))
2 - access("ID"=55)
Note
-----
- rule based optimizer used (consider using cbo)
- Warning: basic plan statistics not available. These are only collected when:
* hint 'gather_plan_statistics' is used for the statement or
* parameter 'statistics_level' is set to 'ALL', at session or system level
SCOTT@test> set autot traceonly
SCOTT@test> Select /*+ rule */ small_vc from t1 where id = 55 and trunc(n1) between 1 and 10 ;
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 1429545322
---------------------------------------------
| Id | Operation | Name |
---------------------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | TABLE ACCESS BY INDEX ROWID| T1 |
|* 2 | INDEX RANGE SCAN | T1_I1 |
---------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TRUNC("N1")<=10 AND TRUNC("N1")>=1)
2 - access("ID"=55)
Note
-----
- rule based optimizer used (consider using cbo)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
3 consistent gets
0 physical reads
0 redo size
325 bytes sent via SQL*Net to client
481 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
--//可以發現在這個版本下10.2.0.3 使用rule提示會使用函式索引.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2154260/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20190918]關於函式索引問題.txt函式索引
- [20211231]函式索引測試.txt函式索引
- [20190827]函式索引與選擇率.txt函式索引
- [20241012]cursor_sharing=force與函式索引.txt函式索引
- [20181123]關於降序索引問題.txt索引
- [20221010]使用toad管理索引改名問題.txt索引
- [20210520]關於主鍵索引問題.txt索引
- [20190910]關於降序索引問題5.txt索引
- [20181124]關於降序索引問題4.txt索引
- [20181124]關於降序索引問題3.txt索引
- [20181124]關於降序索引問題2.txt索引
- [20180408]那些函式索引適合欄位的查詢.txt函式索引
- [20191209]降序索引疑問.txt索引
- 函式呼叫棧的問題函式
- [20191209]降序索引疑問2.txt索引
- [20200303]降序索引疑問5.txt索引
- [20191210]降序索引疑問3.txt索引
- [20191218]降序索引疑問4.txt索引
- [20231026]bbed檢視索引kd_off結構的問題.txt索引
- [20220811]奇怪的隱式轉換問題.txt
- [20200213]函式nullif使用.txt函式Null
- 函式內部This的指向問題函式
- Oracle索引梳理系列(六)- Oracle索引種類之函式索引Oracle索引函式
- MySQL函式索引及優化MySql函式索引優化
- String型別函式傳遞問題型別函式
- 關於cuda中的函式問題函式
- [20231029]使用cygwin調式bash shell引出的問題.txt
- 一類初等函式下取點問題函式
- 阿里雲 函式計算 域名配置問題阿里函式
- sigmod啟用函式和梯度消失問題函式梯度
- Java建構函式的繼承問題Java函式繼承
- [20231123]函式與bash shell呼叫.txt函式
- [20191002]函式dump的bug.txt函式
- [20190728]分析函式LAST_VALUE.txt函式AST
- [20190401]關於semtimedop函式呼叫.txt函式
- [20181002]DBMS_FLASHBACK與函式.txt函式
- [20180531]函式呼叫與遞迴.txt函式遞迴
- 淺談MySql整型索引和字串索引失效或隱式轉換問題汊叄MySql索引字串