Cpu consumption by sessions
                                                 Last update (2008-02-14 11:51:35)
                                                                                                                   Date added (2008-02-13 18:37:21)

SELECT DECODE(TRUNC(SYSDATE - LOGON_TIME), 0, NULL, TRUNC(SYSDATE - LOGON_TIME) || ' Days' || ' + ') ||
TO_CHAR(TO_DATE(TRUNC(MOD(SYSDATE-LOGON_TIME,1) * 86400), 'SSSSS'), 'HH24:MI:SS') LOGON,
s.SID SID, s.serial#, p.spid SPID, s.status, s.username,
UPPER(DECODE(command,
1,'Create Table',2,'Insert',3,'Select',
4,'Create Cluster',5,'Alter Cluster',6,'Update',
7,'Delete', 8,'Drop Cluster', 9,'Create Index',
10,'Drop Index', 11,'Alter Index', 12,'Drop Table',
13,'Create Sequencfe', 14,'Alter Sequence', 15,'Alter Table',
16,'Drop Sequence', 17,'Grant', 18,'Revoke',
19,'Create Synonym', 20,'Drop Synonym', 21,'Create View',
22,'Drop View', 23,'Validate Index', 24,'Create Procedure',
25,'Alter Procedure', 26,'Lock Table', 27,'No Operation',
28,'Rename', 29,'Comment', 30,'Audit',
31,'NoAudit', 32,'Create Database Link', 33,'Drop db Link',
34,'Create Database', 35,'Alter Database', 36,'Create Rollback Segment',
37,'Alter Rollback Segment', 38,'Drop Rollback Segment', 39,'Create Tablespace', 40,'Alter Tablespace', 41,'Drop Tablespace', 42,'Alter Sessions',
43,'Alter User', 44,'Commit', 45,'Rollback',
46,'Savepoint', 47,'PL/SQL Execute', 48,'Set Transaction',
49,'Alter System Switch Log', 50,'Explain Plan', 51,'Create User',
52,'Create Role', 53,'Drop User', 54,'Drop Role',
55,'Set Role', 56,'Create Schema', 57,'Create Control File',
58,'Alter Tracing', 59,'Create Trigger', 60,'Alter Trigger',
61,'Drop Trigger', 62,'Analyze Table', 63,'Analyze Index',
64,'Analyze Cluster', 65,'Create Profile', 66,'Drop Profile',
67,'Alter Profile', 68,'Drop Procedure', 69,'Drop Procedure',
70,'Alter Resource Cost', 71,'Create Snapshot Log', 72,'Alter Snapshot Log',
73,'Drop Snapshot Log', 74,'Create Snapshot', 75,'Alter Snapshot',
76,'Drop Snapshot', 79,'Alter Role', 85,'Truncate Table',
86,'Truncate Cluster', 88,'Alter View', 91,'Create Function',
92,'Alter Function', 93,'Drop Function', 94,'Create Package',
95,'Alter Package', 96,'Drop Package', 97,'Create Package Body',
98,'Alter Package Body', 99,'Drop Package Body')) command,
ROUND((RATIO_TO_REPORT(t.VALUE) OVER ())*100, 2) AS CPU_PERC,
s.machine || '(' || s.osuser || ')' machine_osuser,
s.program, s.module,
t.VALUE CPU_value
FROM v$session s, v$sesstat t, v$statname n, v$process p
WHERE s.SID = t.SID AND
p.addr = s.paddr
AND t.statistic# = n.statistic#
AND n.NAME = 'CPU used by this session'
AND t.VALUE > 0
--AND s.status = 'ACTIVE'
AND audsid > 0
ORDER BY t.VALUE DESC;
Reviews
Categories
Oracle DBA-> (147)
  Alertlog (3)
  Archivelog (5)
  Auditing (1)
  Backup - Recovery (19)
  Database files (6)
  Database options (2)
  DB links (2)
  Dependencies (1)
  Dictionary (2)
  Exp-Imp Datapump (6)
  Jobs (2)
  Mview (2)
  Networking (3)
  Objects (7)
  Parameters (2)
  Redologs (6)
  Roles - Grants (2)
  Rollback - Undo (8)
  Segments (3)
  Sequences (2)
  Sessions (14)
  SGA (14)
  Tables (10)
  Tablespaces (10)
  Temp (4)
  Toad (5)
  Transactions (1)
  Upgrade (2)
  Users (3)
Oracle APPS DBA-> (66)
Exadata (1)
Performance Tuning-> (59)
Oracle Real Cases (24)
Oracle Errors (23)
Oracle SQL tricks (32)
Oracle RAC (3)
Oracle Security (8)
Filters
Search