- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
9#
发表于 2012-3-2 18:15:39
7 楼的问题“重编译包含 session cache cursor 软软解析的数量么?”可能是 说soft soft parse 是否算在总的parse次数内,这个我们可以看下面的演示:
session 1:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> set serveroutput on
SQL> set linesize 200 pagesize 1400
SQL> set time on
21:09:28 SQL> declare
21:09:28 2 l_audsid number;
21:09:28 3 l_sid number;
21:09:28 4 l_serial number;
21:09:28 5 l_module varchar2(128);
21:09:28 6 l_pid number;
21:09:28 7 l_spid number;
21:09:28 8 l_trace varchar2(2000);
21:09:28 9 l_user varchar2(128);
21:09:28 10 begin
DBMS_APPLICATION_INFO.SET_MODULE(module_name => 'Maclean Liu OppO',
21:09:28 11 21:09:28 12 action_name => 'ACTIVE');
21:09:28 13 select audsid, sid, SERIAL#, module,username
21:09:28 14 into l_audsid, l_sid, l_serial, l_module,l_user
21:09:28 15 from v$session
21:09:28 16 where sid = (select distinct sid from v$mystat);
21:09:28 17 select pid, spid
21:09:28 18 into l_pid, l_spid
21:09:28 19 from v$process
21:09:28 20 where addr = (select paddr
21:09:28 21 from v$session
21:09:28 22 where sid = l_sid
and serial# = l_serial);
21:09:28 23 21:09:28 24 SELECT d.VALUE || '/' || LOWER(RTRIM(i.INSTANCE, CHR(0))) || '_ora_' ||
21:09:28 25 p.spid || '.trc'
21:09:28 26 into l_trace
21:09:28 27 FROM (SELECT p.spid
21:09:28 28 FROM v$mystat m, v$session s, v$process p
21:09:28 29 WHERE m.statistic# = 1
21:09:28 30 AND s.SID = m.SID
21:09:28 31 AND p.addr = s.paddr) p,
21:09:28 32 (SELECT t.INSTANCE
21:09:28 33 FROM v$thread t, v$parameter v
21:09:28 34 WHERE v.NAME = 'thread'
21:09:28 35 AND (v.VALUE = 0 OR t.thread# = TO_NUMBER(v.VALUE))) i,
21:09:28 36 (SELECT VALUE FROM v$parameter WHERE NAME = 'user_dump_dest') d;
21:09:28 37
21:09:28 38 dbms_output.enable(9999999);
21:09:28 39 dbms_output.put_line('===============================================');
21:09:28 40 dbms_output.put_line(' USERNAME=' || l_user);
21:09:28 41 dbms_output.put_line(' SESSION ID=' || l_sid || ' SERIAL#=' || l_serial);
21:09:28 42 dbms_output.put_line(' AUDSID=' || l_audsid || ' MODULE#=' ||
21:09:28 43 l_module);
21:09:28 44 dbms_output.put_line(' PID=' || l_pid || ' SPID#=' || l_spid);
21:09:28 45 dbms_output.put_line(' TRACE_FILE_LOCATION=' || l_trace);
21:09:28 46 dbms_output.put_line('===============================================');
21:09:28 47 commit;
21:09:28 48 end;
21:09:28 49 /
===============================================
USERNAME=SYS
SESSION ID=141 SERIAL#=142
AUDSID=4294967295 MODULE#=Maclean Liu OppO
PID=15 SPID#=581
TRACE_FILE_LOCATION=/s01/admin/G10R21/udump/g10r21_ora_581.trc
===============================================
PL/SQL procedure successfully completed.
session 1 的SID 141
session 2 监控 session 1的statistics :
SQL> set linesize 200 pagesize 2000
SQL> col name for a30
SQL> select b.name,a.value, s.username, s.sid, s.serial#
2 from v$sesstat a, v$statname b, v$session s
3 where a.statistic# = b.statistic# and s.sid=a.sid
4 and b.name in ('session cursor cache count','parse count (total)','parse count (hard)')
5 and s.sid=141
6 order by 1
7 /
NAME VALUE USERNAME SID SERIAL#
------------------------------ ---------- ------------------------------ ---------- ----------
parse count (hard) 0 SYS 141 144
parse count (total) 8 SYS 141 144
session cursor cache count 4 SYS 141 144
parse count 8
session cached cursor 4
session 1 运行以下SQL:
SQL>
SQL> declare
2 l_cursor number;
3 begin
4 FOR i IN 1..30000 LOOP
5 l_cursor:=dbms_sql.open_cursor;
6 dbms_sql.parse(l_cursor,'SELECT /* LLLLL */ * FROM dual',dbms_sql.native);
7 dbms_sql.close_cursor(l_cursor);
8 END LOOP;
9 end;
10 /
PL/SQL procedure successfully completed.
同一条SQL 软软解析30000次
session 2 得到的结果:
SQL> select b.name,a.value, s.username, s.sid, s.serial#
2 from v$sesstat a, v$statname b, v$session s
3 where a.statistic# = b.statistic# and s.sid=a.sid
4 and b.name in ('session cursor cache count','parse count (total)','parse count (hard)')
5 and s.sid=141
6 order by 1
7 /
NAME VALUE USERNAME SID SERIAL#
------------------------------ ---------- ------------------------------ ---------- ----------
parse count (hard) 0 SYS 141 144
parse count (total) 30009 SYS 141 144
session cursor cache count 5 SYS 141 144
session cursor cache 多cache 了一个cursor from 4 => 5
parse count 8=> 30009
说明了 soft soft parse 软软解析 算在parse count(total)之内 |
|