[20202117]Function based indexes and cursor sharing.txt
[20202117]Function based indexes and cursor sharing.txt
--//昨天測試給sql打補丁在11g,根據連結介紹https://hourim.wordpress.com/2020/10/24/function-based-indexes-and-cursor-sharing/
--//視乎從19c開始即使設定CURSOR_SHARING=FORCE,對於函式索引可能不需要我介紹的這樣操作。
--//自己測試看看,加強記憶:
1.環境:
TTT@192.168.2.7:1521/orcl> select banner_full from v$version;
BANNER_FULL
----------------------------------------------------------------------
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
2.建立測試例子:
create table t1
as
select
rownum n1,
'xy' || rownum vc1,
mod(rownum, 10) n2
from
dual
connect by
level <= 1e4;
create index idx_t1 on t1(substr(vc1,3,1));
alter session set cursor_sharing=force;
select * from t1 where substr(vc1,3,1)='5';
TTT@192.168.2.7:1521/orcl> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID djypd1v8qjawh, child number 0
-------------------------------------
select * from t1 where substr(vc1,:"SYS_B_0",:"SYS_B_1")=:"SYS_B_2"
Plan hash value: 3491035275
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 3 (100)| |
| 1 | TABLE ACCESS BY INDEX ROWID BATCHED| T1 | 100 | 1400 | 3 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_T1 | 40 | | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
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):
---------------------------------------------------
2 - access("T1"."SYS_NC00004$"=:SYS_B_2)
--//確實如此,對於一些實際生產系統確實是一個大的進步。
TTT@192.168.2.7:1521/orcl> alter session set optimizer_features_enable='12.2.0.1';
Session altered.
TTT@192.168.2.7:1521/orcl> select * from t1 where substr(vc1,3,1)='z';
no rows selected
TTT@192.168.2.7:1521/orcl> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID djypd1v8qjawh, child number 1
-------------------------------------
select * from t1 where substr(vc1,:"SYS_B_0",:"SYS_B_1")=:"SYS_B_2"
Plan hash value: 3617692013
---------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 10 (100)| |
|* 1 | TABLE ACCESS FULL| T1 | 100 | 1400 | 10 (0)| 00:00:01 |
---------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / T1@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(SUBSTR("VC1",:SYS_B_0,:SYS_B_1)=:SYS_B_2)
--//全表掃描,無法使用函式索引。12c還沒有改進。18c已經支援這個功能。不知道那個隱含引數控制這種引為。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2737440/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 建立Function-Based IndexesFunctionIndex
- Function-Based Indexes (199)FunctionIndex
- Uses of Function-Based Indexes (200)FunctionIndex
- [20220414]Function based indexes and cursor sharing2.txtFunctionIndex
- Optimization with Function-Based Indexes (201)FunctionIndex
- Dependencies of Function-Based Indexes (202)FunctionIndex
- Resolve Dependencies of Function-Based Indexes (205)FunctionIndex
- 高效的SQL(Function-based Indexes 函式、運算優化思路)SQLFunctionIndex函式優化
- 使用自定義函式創Function-Based Indexes時需要使用DETERMINISTIC Functions!函式FunctionIndex
- Function-based Index and Or-ExpansionFunctionIndex
- use the function_based index to access the null valueFunctionIndexNull
- Based on the SAP R3 Basis Support Function DetailFunctionAI
- 關於函式索引(function-based index)函式索引FunctionIndex
- 基於函式的索引(function-based index,FBI)函式索引FunctionIndex
- Orale的struct,array,cursor,stored procedure,function,package的用法例子StructFunctionPackage
- Rebuild IndexesRebuildIndex
- ORACLE INDEXESOracleIndex
- Oracle - Tables/IndexesOracleIndex
- Reverse Key IndexesIndex
- ORACLE -> NULL & INDEXESOracleNullIndex
- Overview of Partitioned IndexesViewIndex
- Local Partitioned IndexesIndex
- Global Nonpartitioned IndexesIndex
- Extents in Indexes (19)Index
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- 翻譯(九)——Clustered Indexes: Stairway to SQL Server Indexes Level 3IndexAISQLServer
- skip_unusable_indexesIndex
- The Secrets of Oracle Bitmap IndexesOracleIndex
- Restrictions on Create Bitmap IndexesRESTIndex
- Global Range Partitioned IndexesIndex
- Global Hash Partitioned IndexesIndex
- Maintenance of Global Partitioned IndexesAINaNIndex
- Overview of Indexes (194)ViewIndex
- Indexes and Nulls (198)IndexNull
- shared SQL,parent cursor,child cursorSQL
- 【CURSOR】Oracle 遊標 (cursor)知識梳理Oracle
- Oracle CursorOracle
- Cursor使用