11SQL> @eg3
2- SQL> column ename format a20
3- SQL> column rname format a20
4- SQL>
5- SQL> --
6- SQL> -- Use this to capture a SQL_ID
7- SQL> --
8- SQL> var sqlid varchar2(100)
9- SQL>
10- SQL> --
11- SQL> -- Long running queries will be monitored automatically
12- SQL> -- so the hint won't always be required. In this case,
13- SQL> -- it's over very quickly so I've added the hint.
14- SQL> --
15- SQL> select /*+ MONITOR */
16- 2 e.ename,r.rname
17- 3 from employees e
18- 4 join roles r on (r.id = e.role_id)
19- 5 join departments d on (d.id = e.dept_id)
20- 6 where e.staffno <= 10
21- 7 and d.dname in ('Department Name 1','Department Name 2');
222
233ENAME RNAME
244-------------------- --------------------
255Employee Name 1 Role Name 1
266
27- SQL>
28- SQL> --
29- SQL> -- Get the SQL_ID of the last SQL statement we ran
30- SQL> --
31- SQL> begin
32- 2 select prev_sql_id
33- 3 into :sqlid
34- 4 from v$session
35- 5 where sid=userenv('sid')
36- 6 and username is not null
37- 7 and prev_hash_value <> 0
38- 8 and rownum<2;
39- 9 end;
40- 10 /
417
428PL/SQL procedure successfully completed.
439
44- SQL>
45- SQL> --
46- SQL> -- Text first, then HTML
47- SQL> --
48- SQL> set long 100000 pagesize 0 linesize 250 tab off trims on
49- SQL> column report format a230
50- SQL>
51- SQL> select DBMS_SQL_MONITOR.REPORT_SQL_MONITOR (sql_id=>:sqlid, report_level=>'all', type=>'text') report
52- 2 from dual;
5310SQL Monitoring Report
5411
5512SQL Text
@@ -60,40 +17,37 @@ Global Information
6017------------------------------
6118 Status : DONE (ALL ROWS)
6219 Instance ID : 1
63- Session : ADHOC (63:23029 )
20+ Session : ADHOC (44:61676 )
6421 SQL ID : an05rsj1up1k5
65- SQL Execution ID : 16777226
66- Execution Started : 03/09 /2018 14:23:14
67- First Refresh Time : 03/09 /2018 14:23:14
68- Last Refresh Time : 03/09 /2018 14:23:14
69- Duration : .002638s
22+ SQL Execution ID : 16777228
23+ Execution Started : 03/16 /2018 13:45:05
24+ First Refresh Time : 03/16 /2018 13:45:05
25+ Last Refresh Time : 03/16 /2018 13:45:05
26+ Duration : .001969s
7027 Module/Action : SQL*Plus/-
7128 Service : SYS$USERS
7229 Program : sqlplus@prod12c (TNS V1-V3)
7330 Fetch Calls : 2
7431
7532Global Stats
76- =================================================
77- | Elapsed | Cpu | Other | Fetch | Buffer |
78- | Time(s) | Time(s) | Waits(s) | Calls | Gets |
79- =================================================
80- | 0.00 | 0.00 | 0.00 | 2 | 28 |
81- =================================================
33+ =======================================
34+ | Elapsed | Other | Fetch | Buffer |
35+ | Time(s) | Waits(s) | Calls | Gets |
36+ =======================================
37+ | 0.00 | 0.00 | 2 | 28 |
38+ =======================================
8239
8340SQL Plan Monitoring Details (Plan Hash Value=2341252972)
8441==========================================================================================================================================
8542| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Mem | Activity | Activity Detail |
8643| | | | (Estim) | | Active(s) | Active | | (Actual) | (Max) | (%) | (# samples) |
8744==========================================================================================================================================
8845| 0 | SELECT STATEMENT | | | | 1 | +0 | 1 | 1 | . | | |
89- | 1 | HASH JOIN | | 3 | 6 | 1 | +0 | 1 | 1 | 811KB | | |
90- | 2 | HASH JOIN | | 3 | 4 | 1 | +0 | 1 | 2 | 898KB | | |
46+ | 1 | HASH JOIN | | 3 | 6 | 1 | +0 | 1 | 1 | 523KB | | |
47+ | 2 | HASH JOIN | | 3 | 4 | 1 | +0 | 1 | 2 | 788KB | | |
9148| 3 | TABLE ACCESS FULL | DEPARTMENTS | 2 | 2 | 1 | +0 | 1 | 2 | . | | |
9249| 4 | TABLE ACCESS FULL | EMPLOYEES | 10 | 2 | 1 | +0 | 1 | 10 | . | | |
9350| 5 | TABLE ACCESS FULL | ROLES | 20 | 2 | 1 | +0 | 1 | 20 | . | | |
9451==========================================================================================================================================
9552
9653
97- SQL>
98- SQL> set termout off feedback off
99- SQL> spool monitor_output.html
0 commit comments