[20180912]關於ANSI joins語法.txt
[20180912]關於ANSI joins語法.txt
--//曾經寫過一篇關於ANSI joins的問題,連線:http://blog.itpub.net/267265/viewspace-1988395/
--//提到我個人偏向於使用+語法,連結提到oracle實際上內部轉化為+的語法.
--//最近最佳化中,發現使用qb_name提示,在ANSI joins語法中存在問題.透過例子說明:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
2.使用ansi joins語法:
SCOTT@test01p> select /*+ qb_name(test) */ ename,dname from dept left join emp on dept.deptno=emp.deptno;
...
SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID b5kg9zvurubjy, child number 0
-------------------------------------
select /*+ qb_name(test) */ ename,dname from dept left join emp on
dept.deptno=emp.deptno
Plan hash value: 2251696546
--------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | OMem | 1Mem | Used-Mem |
--------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 5 (100)| | | | |
| 1 | MERGE JOIN OUTER | | 15 | 330 | 5 (0)| 00:00:01 | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 4 | 52 | 2 (0)| 00:00:01 | | | |
| 3 | INDEX FULL SCAN | PK_DEPT | 4 | | 1 (0)| 00:00:01 | | | |
|* 4 | SORT JOIN | | 14 | 126 | 3 (0)| 00:00:01 | 2048 | 2048 | 2048 (0)|
| 5 | TABLE ACCESS FULL | EMP | 14 | 126 | 3 (0)| 00:00:01 | | | |
--------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$0A195698
2 - SEL$0A195698 / DEPT@SEL$1
3 - SEL$0A195698 / DEPT@SEL$1
5 - SEL$0A195698 / EMP@SEL$1
--//前面定義的qb_name(test),也就是Query Block Name不起作用.
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("DEPT"."DEPTNO"="EMP"."DEPTNO")
filter("DEPT"."DEPTNO"="EMP"."DEPTNO")
3.使用+語法:
SCOTT@test01p> select /*+ qb_name(test) */ ename,dname from dept , emp where dept.deptno=emp.deptno(+);
SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID a8m9mmj3j7zgg, child number 0
-------------------------------------
select /*+ qb_name(test) */ ename,dname from dept , emp where
dept.deptno=emp.deptno(+)
Plan hash value: 2251696546
--------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | OMem | 1Mem | Used-Mem |
--------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 5 (100)| | | | |
| 1 | MERGE JOIN OUTER | | 15 | 330 | 5 (0)| 00:00:01 | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 4 | 52 | 2 (0)| 00:00:01 | | | |
| 3 | INDEX FULL SCAN | PK_DEPT | 4 | | 1 (0)| 00:00:01 | | | |
|* 4 | SORT JOIN | | 14 | 126 | 3 (0)| 00:00:01 | 2048 | 2048 | 2048 (0)|
| 5 | TABLE ACCESS FULL | EMP | 14 | 126 | 3 (0)| 00:00:01 | | | |
--------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - TEST
2 - TEST / DEPT@TEST
3 - TEST / DEPT@TEST
5 - TEST / EMP@TEST
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("DEPT"."DEPTNO"="EMP"."DEPTNO")
filter("DEPT"."DEPTNO"="EMP"."DEPTNO")
--//可以發現qb_name定義的提示起作用.
--//可以發現在ansi joins語法中無法很好支援qb_name提示,這樣更加支援我的理由...^_^.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2214073/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20180912]PLSLQ與繫結變數.txt變數
- [20230207]ANSI DATE and TIMESTAMP SQL syntax.txtSQL
- ANSI C定義的一些關於可移植性的術語說明
- [20230905]奇怪的語法.txt
- 關於輸出的小語法點
- Oracle JoinsOracle
- 關於PHP的語法介紹,新手必看PHP
- [20200227]使用tcpdump or and ()語法問題.txtTCP
- [20191202]關於hugepages相關問題.txt
- 【Vue3.0】關於 script setup 語法糖的用法Vue
- [201804012]關於hugepages 3.txt
- [20180306]關於DEFERRED ROLLBACK.txt
- [20210506]]關於ORA-01450.txt
- 關於ES6、ES7的常用語法整理
- [20181123]關於降序索引問題.txt索引
- [20181212]關於truncate reuse storage.txt
- [20190401]關於semtimedop函式呼叫.txt函式
- [20180705]關於hash join 2.txt
- [20190821]關於CPU成本計算.txt
- [20191129]關於hugepages的問題.txt
- [20180306]關於DEFERRED ROLLBACK2.txt
- [20180403]關於時區問題.txt
- [20210527]關於v$wait_chain.txtAI
- [20210410]關於time命令的解析.txt
- Python相關語法2Python
- 關於刷表法
- 聊聊flink Table的Joins
- [20190415]關於shared latch(共享栓鎖).txt
- [20190918]關於函式索引問題.txt函式索引
- [20200223]關於latch and mutext的優化.txtMutex優化
- [20201104]關於稀疏檔案(sparse files).txt
- [20181229]關於字串的分配問題.txt字串
- [20230317]關於TIME_WAIT問題.txtAI
- [20210520]關於主鍵索引問題.txt索引
- CMakeLists.txt 語法介紹與例項演練
- [20191220]關於共享記憶體段相關問題.txt記憶體
- [20190402]關於semtimedop函式呼叫2.txt函式
- [20181124]關於降序索引問題4.txt索引