SQL> col name format a30
SQL> col value format 999,999,999
SQL>
SQL> -- 1. 1st snapshot
SQL> col value new_value prev_value
SQL> select s.sid, n.name, s.value
2 from v$sesstat s,
3 v$statname n ---------<<<<<<<<<<<<<<< stat명으로 비교하기 위해 조인
4 where s.statistic# = n.statistic#
5 and s.sid = userenv('sid')
6 and n.name = 'session logical reads';
SID NAME VALUE
---------- ------------------------------ ------------
151 session logical reads 249,004
SQL>
SQL> -- 1-1. save 1st snapsho
SQL> prompt &prev_value
249004
SQL> -- 2. Workload Process
SQL> select count(*) from all_objects ;
COUNT(*)
----------
45943
SQL>
SQL> -- 3. 2nd snapshot
SQL> col value new_value next_value
SQL> select s.sid, n.name, s.value
2 from v$sesstat s ,
3 v$statname n
4 where s .statistic# = n.statistic#
5 and s.sid = userenv('sid')
6 and n.name = 'session logical reads';
SID NAME VALUE
---------- ------------------------------ ------------
151 session logical reads 322,437
SQL>
SQL> -- 3-1. save 2nd snapshot
SQL> prompt &next_value
322437
SQL> -- Diff
SQL> select (&next_value - &prev_value) as diff from dual;
구 1: select (&next_value - &prev_value) as diff from dual
신 1: select ( 322437 - 249004) as diff from dual
DIFF
----------
73433