Trace event to check explain plan + bind variable peeking + hints + CBO environment

 
Here is description and example about usefull event in 10g:
ORA-10132 dump plan after compilation

When events 10046 level 4 and 10053 are too verbose, this event dumps - for each parsed query:
- the sql statement
- the execution plan ( with predicates, parallel info ... as dbms_xplan does)
- the bind variables used by bind variable peeking
- the hints that can be used to force this execution plan (as outlines do)
- the optimizer environment

Notes:
- it can be used in 9i but there is not all those information available in 10g
- you will have dump generated only when statement is parsed
- information comes from http://jonathanlewis.wordpress.com/2006/11/27/event-10132/
- you can have more trace on 'why' the CBO choose that execution plan with event 'ORA-10053: CBO Enable optimizer trace'

Here is an example: the following script

column value new_value uniquenumber
select value from v$sysstat where statistic#=6;
variable e number;
exec :e:=7698;
alter session set events='10132 trace name context forever, level 1';
select /* &uniquenumber used to parse each time */count(*) from scott.emp where empno > :e;
alter session set events='10132 trace name context off';

generates the following trace:

sql_id=3w7fap1vgs6ph.
Current SQL statement for this session:
select /* 8144 */count(*) from scott.emp where empno > :e

============
Plan Table
============
-------------------------------------+-----------------------------------+
| Id | Operation | Name | Rows | Bytes | Cost | Time |
-------------------------------------+-----------------------------------+
| 0 | SELECT STATEMENT | | | | 1 | |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
| 2 | INDEX RANGE SCAN | PK_EMP | 6 | 18 | 1 | 00:00:01 |
-------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - access("EMPNO">:E)

Content of other_xml column
===========================
db_version : 10.2.0.1
parse_schema : FRANCK
plan_hash : 109489892
Peeked Binds
============
Bind variable information
position=1
datatype(code)=2
datatype(string)=NUMBER
precision=0
scale=0
max length=22
value=7698
Outline Data:
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('10.2.0.1')
ALL_ROWS
OUTLINE_LEAF(@"SEL$1")
INDEX(@"SEL$1" "EMP"@"SEL$1" ("EMP"."EMPNO"))
END_OUTLINE_DATA
*/

Optimizer environment:
optimizer_mode_hinted = false
optimizer_features_hinted = 0.0.0
parallel_execution_enabled = true
parallel_query_forced_dop = 0
... all parameters (documented or hidden) that are used by the CBO ...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值