[20210627]cursor_sharing=force與orade by.txt
[20210627]cursor_sharing=force與orade by.txt
--//今天看了連結https://connor-mcdonald.com/2021/07/05/cursor_sharing-and-order-by/
--//實際上不知道是否巧合,前幾天我也看到這句話.
If a statement uses an ORDER BY clause, then the database does not perform
literal replacement in the clause because it is not semantically correct to
consider the constant column number as a literal. The column number in
the ORDER BY clause affects the query plan and execution, so the database
cannot share two cursors having different column numbers.
--//我看到的這個內容來之sql-tuning-guide.pdf. 21c F31828-03 December 2020.我當時的測試就是不想上面說的情況.
--//以前是我的測試:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
2.測試:
SCOTT@test01p> alter session set cursor_sharing=force ;
Session altered.
SCOTT@test01p> select * from dept where deptno=10 order by 1;
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID f2jf1h54abkzu, child number 0
-------------------------------------
select * from dept where deptno=:"SYS_B_0" order by :"SYS_B_1"
Plan hash value: 2852011669
----------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 1 (100)| |
| 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 20 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| |
----------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$9FB2EC53 / DEPT@SEL$1
2 - SEL$9FB2EC53 / DEPT@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DEPTNO"=:SYS_B_0)
--//替換髮生,並沒有連結介紹的情況.
--//執行如下也是一樣 select * from dept where deptno=10 order by 2;
--//換一種方式:
SCOTT@test01p> select * from dept where dname='ACCOUNTING' order by 2;
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 087vcgdqz87g9, child number 0
-------------------------------------
select * from dept where dname=:"SYS_B_0" order by :"SYS_B_1"
Plan hash value: 3383998547
---------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 3 (100)| |
|* 1 | TABLE ACCESS FULL| DEPT | 1 | 20 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
SCOTT@test01p> select * from dept where dname='ACCOUNTING' order by 1;
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 087vcgdqz87g9, child number 1
-------------------------------------
select * from dept where dname=:"SYS_B_0" order by :"SYS_B_1"
Plan hash value: 3103054919
----------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100)| |
|* 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 20 | 2 (0)| 00:00:01 |
| 2 | INDEX FULL SCAN | PK_DEPT | 4 | | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / DEPT@SEL$1
2 - SEL$1 / DEPT@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("DNAME"=:SYS_B_0)
--//還是有效.
select * from dept where dname='ACCOUNTING' order by 1,2;
select * from dept where dname='ACCOUNTING' order by 2,1;
select * from dept where dname='ACCOUNTING' order by 2,3;
select * from dept where dname='ACCOUNTING' order by 3,2;
--//一樣有效,自不過產生許多子游標罷了.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2780014/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20241012]cursor_sharing=force與函式索引.txt函式索引
- [20180803]cursor_sharing = force.txt
- [20200117]push_pred distinct group by.txt
- cursor_sharing=force強制繫結變數不會把變數值預設當成varchar2型別的理解變數型別
- [20240325]FORCE_MATCHING_SIGNATURE與DML.txt
- House Of Force
- ACID(Force & Steal)
- ORACLE中Cursor_sharing引數詳解Oracle
- DVWA之Brute Force
- 2.5.11 指定 FORCE LOGGING 模式模式
- 2.5.11.1 使用 FORCE LOGGING 子句
- 初始化引數遊標之cursor_sharing
- [譯] 使用 `-force` 被認為是有害的;瞭解 Git 的 `-force-with-lease` 命令Git
- DVWA-Brute Force暴力破解
- nologging、force logging、supplemental log的理解
- DVWA靶場學習(一)—— Brute Force
- PostgreSQL DBA(138) - PG 13(Drop database force)SQLDatabase
- Yuan Force收購萬順醫療MFV
- 日誌記錄模式(LOGGING 、FORCE LOGGING 、NOLOGGING)模式
- Vivado使用技巧(3):Force Up-to-Date功能
- terrans force筆記本怎麼安裝win10_terrans force電腦安裝win10教程【圖文】筆記Win10
- idea Git Force Checkout後的解決辦法IdeaGit
- D3原始碼解讀系列之Force原始碼
- Plugin Alliance WEDGE FORCE Matcha for mac(吉他合成器)PluginMac
- 2.5.11.2 FORCE LOGGING 模式需要考慮的效能問題模式
- Meta Force佛薩奇2.0系統開發的邏輯需求 | Meta Force佛薩奇2.0系統開發原始碼示例原始碼
- IBM:2023年X-Force威脅情報指數IBM
- FORCE矩陣公智慧合約系統開發軟體矩陣
- 「暑期訓練」「Brute Force」 Multiplication Table (CFR256D2D)
- 「暑期訓練」「Brute Force」 Bitonix' Patrol (CFR134D1D)
- 「暑期訓練」「Brute Force」 Restoring Painting (CFR353D2B)RESTAI3D
- 佛薩奇2.0(Meta force)矩陣系統開發原始碼矩陣原始碼
- [20221207]為什麼FORCE_MATCHING_SIGNATURE不一致.txt
- Meta Force原力元宇宙系統開發部署理念講解元宇宙
- Meta佛薩奇2.0Force系統技術開發(原理分析)
- 案例:DG主庫未設定force logging導致備庫壞塊
- IBM X-Force:自2015年以來 黑客攻擊已下降95%IBM黑客
- Meta force佛薩奇NFT系統開發原始碼技術介紹原始碼