Bug 9290526 - Poor plan for recursive SQL used for DML involving a UNIQUE constraint [ID 9290526.8]
|
A suboptimal plan may be seen for the specific recursive SQL:
select c.name, u.name
from con$ c, cdef$ cd, user$ u where c.con# = cd.con# and cd.enabled =:1 and
c.owner# = u.user#;
This can cause inserts involving a unique constraint to show poor performance.
Workaround
Set optimizer_mode=rule for the affected DMLs.
plan for
2 select c.name, u.name from con$ c, cdef$ cd, user$ u where c.con# =
3 cd.con# and cd.enabled = :v1 and c.owner# = u.user#;
Explained.
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 2222027377
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 7 | 336 | 10 (10)| 00:00:01 |
|* 1 | HASH JOIN | | 7 | 336 | 10 (10)| 00:00:01 |
|* 2 | HASH JOIN | | 7 | 203 | 8 (13)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| CDEF$ | 7 | 56 | 2 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | I_CDEF4 | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS FULL | CON$ | 3584 | 75264 | 5 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | USER$ | 33 | 627 | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("C"."OWNER#"="U"."USER#")
2 - access("C"."CON#"="CD"."CON#")
4 - access("CD"."ENABLED"=TO_NUMBER(:V1))
20 rows selected.
plan for
2 select /*+ rule */ c.name, u.name from con$ c, cdef$ cd, user$ u where c.con# = cd.con# and cd.enabled = :v1 and c.owner# = u.user#;
Explained.
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1027684349
-------------------------------------------------
| Id | Operation | Name |
-------------------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | NESTED LOOPS | |
| 2 | NESTED LOOPS | |
| 3 | TABLE ACCESS BY INDEX ROWID| CDEF$ |
|* 4 | INDEX RANGE SCAN | I_CDEF4 |
| 5 | TABLE ACCESS BY INDEX ROWID| CON$ |
|* 6 | INDEX UNIQUE SCAN | I_CON2 |
| 7 | TABLE ACCESS CLUSTER | USER$ |
|* 8 | INDEX UNIQUE SCAN | I_USER# |
-------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("CD"."ENABLED"=TO_NUMBER(:V1))
6 - access("C"."CON#"="CD"."CON#")
8 - access("C"."OWNER#"="U"."USER#")
Note
-----
- rule based optimizer used (consider using cbo)
26 rows selected.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7591490/viewspace-1058153/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Bug 2784796: ORA-00001:UNIQUE CONSTRAINTAI
- Data Warehouse Guide閱讀筆記(六):unique constraint & unique indexGUIIDE筆記AIIndex
- ORA-00001: unique constraint (PERFSTAT.STATS$SQL_SUMMARY_PK) violated 解決方法AISQL
- ORA-02429: cannot drop index used for enforcement of unique/primary keyIndex
- SQL Plan ManagementSQL
- 產生遞迴呼叫 (Recursive Call 或 recursive SQL statements) 的幾種情況遞迴SQL
- Identify If A Disk/Part Is Still Used By ASM,Used by ASM Or Used by ASM_603210.1IDEASM
- ORA-00001 Unique Constraint SYS.I_JOB_JOB ViolatedAI
- SQL Plan Management(SPM)SQL
- SQL Server Unique ConstratintsSQLServer
- ORA-00001 : Unique Constraint Violated caused by DATE VS Timestamp(6)AI
- RMAN Restore Performance from Tape is Very Poor (Doc ID 850988.1)RESTORM
- SQL Plan Management介紹SQL
- ORA-00001: UNIQUE CONSTRAINT (SYS.WRI$_SQLSET_PLANS_PK) VIOLATEDAISQL
- Recursive Algorithm for Sliding Signal ProcessingGo
- :[IBM][ODBC Oracle Wire Protocol driver][Oracle]ORA-00001: unique constraint (SCIBMOracleProtocolAI
- sql_plan_baselineSQL
- SQL PLAN Management的測試SQL
- WRH$_SQL_PLAN 被鎖SQL
- 11g-sql plan managementSQL
- sql plan baselines(一)SQL
- sql plan baseline(二)SQL
- 【SQL_PLAN】Oracle 透過檢視sql_plan 格式化執行計劃SQLOracle
- 使用V$SQL_PLAN檢視SQL
- v$sql_plan 檢視解析SQL
- 用EXPLAIN PLAN 分析SQL語句AISQL
- get_plan_by_sqlidSQL
- SQL學習___03:DML語法SQL
- ORA-00001: unique constraint (...) violated並不一定是資料衝突AI
- Constraint State(disable/enable validate/noalidate)AI
- Default Data Type Mappings Used by Oracle SQL DeveloperAPPOracleSQLDeveloper
- dbms_xplan.display_cursor 報錯 NOTE: cannot fetch plan for SQL_IDSQL
- 高效的SQL(Index unique scan最優化)SQLIndex優化
- SAP ABAP SQL的execution plan和cacheSQL
- sql plan baseline使用心得SQL
- Retrieve SQL and Execution Plan from AWR SnapshotsSQL
- SQL Plan Baselines 實驗01SQL
- Oracle SQL Plan Baseline 學習OracleSQL