[ORALCE]SQL 优化案例之 10046事件,查看硬解析

1.开启10046事件

drop table TX1 purge;
create table TX1 (x int);
set linesize 266
set pagesize 5000
alter system flush shared_pool;
alter system flush buffer_cache;
alter session set events '10046 trace name context forever,level 12';

2.批量硬解析操作

begin
    for i in 1..100000
    loop 
        execute immediate
        'insert into TX1 values ('||i||')';
    end loop;
    commit;
end;
/

3.关闭10046事件

alter session set events '10046 trace name context off';

4.查看生成trace 文件

SQL> select tracefile from v$process where addr in (select paddr from v$session where sid in (select sid from v$mystat));

TRACEFILE
--------------------------------------------------------------------------------
/oracle/D4C/diag/rdbms/d4cdb/D4C/trace/D4C_ora_10115.trc

5.通过tkpro 生成文件

[oracle@d4cdb trace]$ tkprof D4C_ora_10115.trc hardparasenosys.txt aggregate=yes sys=no waits=yes sort=fchela

TKPROF: Release 19.0.0.0.0 - Development on Fri May 8 21:30:54 2020

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

[oracle@d4cdb trace]$ ls -ltr hardparasenosys.txt 
-rw-r--r-- 1 oracle oinstall 3893 May  8 21:37 hardparasenosys.txt

5.查看tkpro 生成文件,可以看到由于没有绑定变量产生了很多PARSE.

[ORALCE]SQL 优化案例之  10046事件,查看硬解析

 

上一篇:五分钟打造自己的sql性能分析工具


下一篇:oracle 体系_第三章控制文件