利用hints控制outline
SQL> variable aa number;
SQL> exec :aa:=90;
PL/SQL 過程已成功完成。
SQL> select * from tt where id=:aa;
ID MC
---------- --------------------
90 1
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TT'
2 1 INDEX (UNIQUE SCAN) OF 'TT_PK' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
422 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> create or replace outline ol1 for category test_ol on
2 select * from tt where id=:aa;
大綱已建立。
SQL> create or replace outline ol2 for category test_ol on
2 select /*+FULL(tt)*/ * from tt where id=:aa;
大綱已建立。
SQL> desc dba_outlines
名稱 是否為空? 型別
----------------------------------------- -------- ----------------------------
NAME VARCHAR2(30)
OWNER VARCHAR2(30)
CATEGORY VARCHAR2(30)
USED VARCHAR2(9)
TIMESTAMP DATE
VERSION VARCHAR2(64)
SQL_TEXT LONG
SIGNATURE RAW(16)
SQL> col name for a10
SQL> select name,used from dba_outlines;
NAME USED
---------- ---------
OL1 UNUSED
OL2 UNUSED
SQL> desc dba_outline_hints
名稱 是否為空? 型別
----------------------------------------- -------- ----------------------------
NAME VARCHAR2(30)
OWNER VARCHAR2(30)
NODE NUMBER
STAGE NUMBER
JOIN_POS NUMBER
HINT VARCHAR2(512)
SQL> col hint for a20
SQL> col name for a10
SQL> select name,node,stage,join_pos,hint from dba_outline_hints;
NAME NODE STAGE JOIN_POS HINT
---------- ---------- ---------- ---------- --------------------
OL1 1 3 0 NO_EXPAND
OL1 1 3 0 ORDERED
OL1 1 3 0 NO_FACT(TT)
OL1 1 3 1 INDEX(TT TT_PK)
OL1 1 2 0 NOREWRITE
OL1 1 1 0 NOREWRITE
OL1 1 1 0 RULE
OL2 1 3 0 NO_EXPAND
OL2 1 3 0 ORDERED
OL2 1 3 0 NO_FACT(TT)
OL2 1 3 1 FULL(TT)
NAME NODE STAGE JOIN_POS HINT
---------- ---------- ---------- ---------- --------------------
OL2 1 2 0 NOREWRITE
OL2 1 1 0 NOREWRITE
已選擇13行。
SQL> update outln.ol$hints
2 set ol_name =decode(ol_name,
3 'OL1','OL2',
4 'OL2','OL1')
5 where ol_name in ('OL1','OL2');
已更新13行。
SQL> update outln.ol$ ol1
2 set hintcount = (select hintcount from outln.ol$ ol2
3 where ol2.ol_name in ('OL1','OL2')
4 and ol2.ol_name != ol1.ol_name)
5 where ol1.ol_name in ('OL1','OL2');
已更新2行。
SQL> COMMIT;
提交完成。
SQL> select name,node,stage,join_pos,hint from dba_outline_hints;
NAME NODE STAGE JOIN_POS HINT
---------- ---------- ---------- ---------- --------------------
OL2 1 3 0 NO_EXPAND
OL2 1 3 0 ORDERED
OL2 1 3 0 NO_FACT(TT)
OL2 1 3 1 INDEX(TT TT_PK)
OL2 1 2 0 NOREWRITE
OL2 1 1 0 NOREWRITE
OL2 1 1 0 RULE
OL1 1 3 0 NO_EXPAND
OL1 1 3 0 ORDERED
OL1 1 3 0 NO_FACT(TT)
OL1 1 3 1 FULL(TT)
NAME NODE STAGE JOIN_POS HINT
---------- ---------- ---------- ---------- --------------------
OL1 1 2 0 NOREWRITE
OL1 1 1 0 NOREWRITE
已選擇13行。
SQL> alter session set use_stored_outlines=test_ol;
會話已更改。
SQL> select name,used from dba_outlines;
NAME USED
---------- ---------
OL1 UNUSED
OL2 UNUSED
SQL> select * from tt where id=:aa;
ID MC
---------- --------------------
90 1
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=1 Bytes=25)
1 0 TABLE ACCESS (FULL) OF 'TT' (Cost=2 Card=1 Bytes=25)
Statistics
----------------------------------------------------------
69 recursive calls
4 db block gets
15 consistent gets
0 physical reads
612 redo size
422 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select name,used from dba_outlines;
NAME USED
---------- ---------
OL1 USED
OL2 UNUSED
10G以後可以用dbms_outln.CREATE_OUTLINE來建立:
BEGIN
DBMS_OUTLN.create_outline(
hash_value => 921600969,
child_number => 0,
category => 'TEST_OUTLINE');
END;
/
SELECT sql_id,hash_value,outline_category,sql_text FROM v$sqlarea WHERE hash_value=921600969;
參看metalink
Note:604022.1 How To Force A Query To Used Index Hint With Stored Outline
Note:730062.1 How to Edit a Stored Outline to Use the Plan from Another Stored Outline
Note:144194.1 Editing Stored Outlines in Oracle9i - an example
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-544642/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- WITH AS and materialize hints
- Using hints for PostgresqlSQL
- 【譯】Resource Hints
- Extended Window Manager Hints(1)
- CSS outline-style 屬性: CSS3 outline-CSSS3
- Python -型別提示 Type HintsPython型別
- Pycharm,Python 3 與 Type HintsPyCharmPython
- outline初體驗
- CSS outline輪廓CSS
- Outline for Mac(筆記軟體)Mac筆記
- outline優化一例優化
- Python Type Hints 從入門到實踐Python
- SAP: SALV 利用控制器的模式模式
- CSS 不規則的輪廓-outlineCSS
- 在繫結變數下使用outline變數
- 對專案版本自動控制——利用gitversionGit
- Outline for Mac(筆記本編輯軟體)Mac筆記
- 邊框(Border) 和 輪廓(Outline) 屬性
- 根據google的outline科學上網Go
- oracle使用outline固定執行計劃事例Oracle
- 利用swagger和API Version實現api版本控制SwaggerAPI
- golang 利用 WaitGroup 控制多個 goroutine 同時完成GolangAI
- Outline for mac (Mac筆記本編輯軟體)Mac筆記
- 超實用的筆記軟體:Outline for Mac筆記Mac
- 利用react-to-web-component封裝react控制元件ReactWeb封裝控制元件
- 好用的mac筆記軟體推薦:Outline for MacMac筆記
- 【YashanDB知識庫】崖山資料庫Outline功能驗證資料庫
- CSS並不簡單–走進border、box-shadow和outlineCSS
- 新手入門教程:如何將Evernote筆記本匯入到Outline筆記
- Vue2-利用自定義指令實現按鈕許可權控制Vue
- Azure Terraform(九)利用 Azure DevOps Pipeline 的審批來控制流程釋出ORMdev
- 微信授權報code been used, hints: [ req_id: XYv1Ha07042046 ]
- Java利用Redis實現非同步邏輯多使用者併發控制JavaRedis非同步
- 利用STM32VET6控制TEF6686(V102)收音機晶片晶片
- Asp.Net Core中利用過濾器控制Nginx的快取時間ASP.NET過濾器Nginx快取
- 攻擊者宣稱可利用 0day 漏洞完全控制 Android 手機Android
- [WCF許可權控制]利用WCF自定義授權模式提供當前Principal模式
- 利用魯棒控制實現深度強化學習駕駛策略的遷移強化學習