[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20180212]函式索引問題.txt函式索引
- 函式索引的問題函式索引
- [20190918]關於函式索引問題.txt函式索引
- 關於函式索引的問題?函式索引
- [20150803]使用函式索引注意的問題.txt函式索引
- 0427建立Extended Statistics函式索引問題函式索引
- 0429建立Extended Statistics函式索引問題函式索引
- [20120130]函式索引與取max值的問題1.txt函式索引
- [20120131]函式索引與取max值的問題2.txt函式索引
- [20120131]函式索引與取max值的問題3.txt函式索引
- [20120612]函式索引中使用substr函式.txt函式索引
- [20170402]函式索引standard_hash.txt函式索引
- 建立聯合函式索引解決top sql效能問題函式索引SQL
- 利用函式索引解決複雜的約束問題函式索引
- [20120201][補充]函式索引與取max值的問題1.txt函式索引
- [20190827]函式索引與選擇率.txt函式索引
- [20211231]函式索引測試.txt函式索引
- 函式索引陷阱函式索引
- oracle函式索引Oracle函式索引
- 函式索引使用細節——自定義函式的索引化函式索引
- [20171202]關於函式索引的狀態.txt函式索引
- 小問題-用分析函式求平均時間段的統計數.txt函式
- Oracle之函式索引Oracle函式索引
- 說說函式索引函式索引
- 索引中使用函式索引函式
- 關於Hash 函式 雜湊索引表 解決位置衝突的問題函式索引
- 函式呼叫棧的問題函式
- itoa函式的奇怪問題函式
- 基於函式的索引函式索引
- deterministic function 函式索引Function函式索引
- 函式索引的儲存函式索引
- SQL優化--函式索引SQL優化函式索引
- sequence 和索引函式呼叫索引函式
- [20241012]cursor_sharing=force與函式索引.txt函式索引
- 函式內部This的指向問題函式
- 關於scanf函式的問題函式
- 批量註冊事件處理函式索引總是最後一個問題解決事件函式索引
- [20180408]那些函式索引適合欄位的查詢.txt函式索引