oracle hint /*+ BYPASS_UJVC*/ 使用案例
var B2 number;
exec :B2:=530;
var B1 number;
exec :B1:=201411;
UPDATE PRERPT.STATQ_WRTOFF_PLYD_PRE P SET GFLAG = 1 WHERE EXISTS (SELECT 1 FROM PRERPT.STATB_GROUP_ACCOUNT T WHERE T.REGION = :B2 AND T.CYCLE = :B1
AND T.ACCTID = P.ACCTID )
該語句由於沒有選擇正確的執行計劃,導致語句非常慢
Plan hash value: 4033170240
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost | Pstart | Pstop |
---------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | | | 23 | | |
| 1 | UPDATE | | | | | | |
| * 2 | HASH JOIN SEMI | | 2 | 130 | 23 | | |
| 3 | PARTITION RANGE ALL | | | | | 1 | 17 |
| 4 | TABLE ACCESS FULL | STATQ_WRTOFF_PLYD_PRE | 1394 | 36244 | 3 | 1 | 17 | =======〉該表大應該是被驅動表,在這裡反而是驅動表。
| 5 | PARTITION RANGE SINGLE | | | | | KEY | KEY |
| * 6 | TABLE ACCESS FULL | STATB_GROUP_ACCOUNT | 1 | 39 | 19 | KEY | KEY | ========〉該結果集返回的行資料少,應該是驅動表但這裡是被驅動表。
---------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ACCTID"="ACCTID")
6 - filter("REGION"=:B2 AND "CYCLE"=:B1)
透過對上述語句進行改寫,直接update一檢視來完成驅動表和被驅動表的轉變。由於UPDATE檢視要求T具有唯一索引,所在必須要加上Hint /*+ BYPASS_UJVC*/ 來避免唯一性檢查。
UPDATE (SELECT /*+ BYPASS_UJVC use_hash(p,t) leading(t) */
p.gflag
FROM prerpt.statq_wrtoff_plyd_pre p
INNER JOIN (SELECT DISTINCT acctid
FROM prerpt.statb_group_account t
WHERE t.region = :b2
AND t.cycle = :b1) t
ON t.acctid = p.acctid)
SET gflag = 1
exec :B2:=530;
var B1 number;
exec :B1:=201411;
UPDATE PRERPT.STATQ_WRTOFF_PLYD_PRE P SET GFLAG = 1 WHERE EXISTS (SELECT 1 FROM PRERPT.STATB_GROUP_ACCOUNT T WHERE T.REGION = :B2 AND T.CYCLE = :B1
AND T.ACCTID = P.ACCTID )
該語句由於沒有選擇正確的執行計劃,導致語句非常慢
Plan hash value: 4033170240
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost | Pstart | Pstop |
---------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | | | 23 | | |
| 1 | UPDATE | | | | | | |
| * 2 | HASH JOIN SEMI | | 2 | 130 | 23 | | |
| 3 | PARTITION RANGE ALL | | | | | 1 | 17 |
| 4 | TABLE ACCESS FULL | STATQ_WRTOFF_PLYD_PRE | 1394 | 36244 | 3 | 1 | 17 | =======〉該表大應該是被驅動表,在這裡反而是驅動表。
| 5 | PARTITION RANGE SINGLE | | | | | KEY | KEY |
| * 6 | TABLE ACCESS FULL | STATB_GROUP_ACCOUNT | 1 | 39 | 19 | KEY | KEY | ========〉該結果集返回的行資料少,應該是驅動表但這裡是被驅動表。
---------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ACCTID"="ACCTID")
6 - filter("REGION"=:B2 AND "CYCLE"=:B1)
透過對上述語句進行改寫,直接update一檢視來完成驅動表和被驅動表的轉變。由於UPDATE檢視要求T具有唯一索引,所在必須要加上Hint /*+ BYPASS_UJVC*/ 來避免唯一性檢查。
UPDATE (SELECT /*+ BYPASS_UJVC use_hash(p,t) leading(t) */
p.gflag
FROM prerpt.statq_wrtoff_plyd_pre p
INNER JOIN (SELECT DISTINCT acctid
FROM prerpt.statb_group_account t
WHERE t.region = :b2
AND t.cycle = :b1) t
ON t.acctid = p.acctid)
SET gflag = 1
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29446986/viewspace-1354557/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE使用HINT的方法Oracle
- Oracle索引HINT的使用Oracle索引
- Oracle之Hint使用總結Oracle
- oracle 多表連合修改----BYPASS_UJVC(轉)Oracle
- 索引反向使用案例,加index_desc hint索引Index
- oracle hintOracle
- Oracle中“HINT”的使用方法Oracle
- oracle經常使用到的hintOracle
- ORACLE 部分HINTOracle
- oracle hint (續)Oracle
- Oracle Hint 精華Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(五)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(四)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(三)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(二)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(一)Oracle
- oracle之hint概述Oracle
- oracle常見hintOracle
- oracle hint簡述Oracle
- oracle hint (續-0)Oracle
- oracle hint_no_indexOracleIndex
- Oracle Hint 精華文章Oracle
- 常用的Oracle HintOracle
- Oracle Hint 詳解Oracle
- Oracle Hint的用法Oracle
- 【微信公眾號● DBAplus】Oracle原廠老兵:從負面案例看Hint的最佳使用方式Oracle
- 使用Oracle Hint提示來更改執行計劃Oracle
- oracle hint之hint_index_ffs,index_joinOracleIndex
- 【HINT】使用“NO_INDEX ”Hint提示避免SQL使用特定索引IndexSQL索引
- ORACLE的HINT詳解Oracle
- Oracle中Hint隨記Oracle
- oracle hint no_mergeOracle
- oracle hint_no_expand_no_factOracle
- oracle hint_cache_nocacheOracle
- Oracle 常用HINT介紹Oracle
- (轉)Oracle Hint的用法Oracle
- oracle hint有效範圍Oracle
- Oracle中的sql hintOracleSQL