[20201130]11g or_expand提示.txt
[20201130]11g or_expand提示.txt
--//最近看了幾篇使用or_expand提示的文章,我發現實際上在11g根本無法使用,做1個記錄。只能使用USE_CONCAT提示。
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
SCOTT@book> @ sqlhint or_expand
NAME SQL_FEATURE CLASS INVERSE TARGET_LEVEL PROPERTY VERSION VERSION_OUTLINE
--------- --------------- --------- ------------------------------ ------------ ---------- -------------- -------------------------
OR_EXPAND QKSFM_OR_EXPAND OR_EXPAND 4 272 8.1.7
--//說明這個提示是存在的。
SCOTT@book> @ sqlhint concat
NAME SQL_FEATURE CLASS INVERSE TARGET_LEVEL PROPERTY VERSION VERSION_OUTLINE
---------- ---------------- ---------- ---------- ------------ ---------- ------------------------- -------------------------
USE_CONCAT QKSFM_USE_CONCAT USE_CONCAT NO_EXPAND 2 16 8.1.0 8.1.7
--//USE_CONCAT的相反是NO_EXPAND。這個提示感覺命名不是太好。
2.測試:
SCOTT@book> create index i_emp_ename on emp(ename);
Index created.
SCOTT@book> select /*+ or_expand */ * from emp where empno=7369 or ename like 'S%' ;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7788 SCOTT ANALYST 7566 1987-04-19 00:00:00 3000 20
7369 SMITH CLERK 7902 1980-12-17 00:00:00 800
Plan hash value: 407431354
---------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
---------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 3 (100)| |
| 1 | CONCATENATION | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| EMP | 2 | 76 | 2 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | I_EMP_ENAME | 2 | | 1 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 38 | 1 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 0 (0)| |
---------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1_1 / EMP@SEL$1
3 - SEL$1_1 / EMP@SEL$1
4 - SEL$1_2 / EMP@SEL$1_2
5 - SEL$1_2 / EMP@SEL$1_2
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("ENAME" LIKE 'S%')
filter("ENAME" LIKE 'S%')
4 - filter(LNNVL("ENAME" LIKE 'S%'))
5 - access("EMPNO"=7369)
--//實際上使用的USE_CONCAT。
--//換一句話講11g根本不支援or_expand提示最佳化。看看no_expand提示。
SCOTT@book> select /*+ no_expand(@sel$1 ) */ * from emp where empno=7369 or ename = 'S';
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
SCOTT@book> @ dpc '' advanced
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 4zgthyh2j6jya, child number 0
-------------------------------------
select /*+ no_expand(@sel$1 ) */ * from emp where empno=7369 or ename =
'S'
Plan hash value: 3589351319
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 3 (100)| |
| 1 | TABLE ACCESS BY INDEX ROWID | EMP | 2 | 76 | 3 (0)| 00:00:01 |
| 2 | BITMAP CONVERSION TO ROWIDS | | | | | |
| 3 | BITMAP OR | | | | | |
| 4 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 5 | INDEX RANGE SCAN | PK_EMP | | | 0 (0)| |
| 6 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 7 | INDEX RANGE SCAN | I_EMP_ENAME | | | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------
SCOTT@book> select /*+ no_expand(@sel$1 ) */ * from emp where empno=7369 or ename like 'S%';
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
7788 SCOTT ANALYST 7566 1987-04-19 00:00:00 3000 20
Plan hash value: 3956160932
---------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 3 (100)| |
|* 1 | TABLE ACCESS FULL| EMP | 3 | 114 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / EMP@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(("EMPNO"=7369 OR "ENAME" LIKE 'S%'))
--//總之我在11g下無法實現or_expand.另外感覺如果支援or_expand提示的話,use_concat與or_expand非常相似,
--//那位能講講兩者的那些不同。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2738350/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20181220]使用提示OR_EXPAND優化.txt優化
- [20190524]使用use_concat or_expand提示優化.txt優化
- [20190306]11g health monitor.txt
- [20190219]那個更快(11g).txt
- [20211025]11g sequemce nocahe測試.txt
- [20201126]11g VPD的問題.txt
- [20201210]11G ACS相關問題.txt
- [20191211]11g streams_pool_size引數.txt
- [20190416]11g下那些latch是Exclusive的.txt
- [20190415]11g下那些latch是共享的.txt
- [20190214]11g Query Result Cache RC Latches.txt
- [20180928]如何能在11g下執行.txt
- [20211213]提示precompute_subquery.txt
- [20210120]提示加入註解.txt
- [20180927]修改sql prompt提示.txtSQL
- [20201116]測試CURSOR_SPACE_FOR_TIME=false(11g).txtFalse
- [20181112]11g 日誌傳輸壓縮模式.txt模式
- [20190214]11g Query Result Cache RC Latches補充.txt
- [20180819]關於父子游標問題(11g).txt
- [20180503]檢視提示使用索引.txt索引
- [20201106]11g修改表無需修改許可權.txt
- [20211215]提示precompute_subquery補充.txt
- [20201106]11g查詢DBA_TAB_MODIFICATIONS無輸出.txt
- [20201116]11g連線謂詞推入push_pred問題.txt
- [20210520]11g shared pool latch與library cache mutex的簡單探究.txtMutex
- [20211221]提示precompute_subquery補充2.txt
- [20241108]跟蹤library cache lock library cache pin使用gdb(11g)4.txt
- [20241108]跟蹤library cache lock library cache pin使用gdb(11g)3.txt
- [20241105]跟蹤library cache lock library cache pin使用gdb(11g)2.txt
- [20220815]奇怪的隱式轉換問題(11g測試補充).txt
- [20210304]關於11g一致性讀取的測試.txt
- [20220517]toad使用gather_plan_statistics提示問題.txt
- [20211115]配置logrotate提示parent directory has insecure permissions.txtlogrotate
- [20210929]sql打補丁使用rule提示問題.txtSQL
- [20191213]toad 12下BIND_AWARE提示無效.txt
- [20210521]11g shared pool latch與library cache mutex的簡單探究4.txtMutex
- [20210520]11g shared pool latch與library cache mutex的簡單探究3.txtMutex
- [20230329]利用bind_aware提示最佳化案例2.txt