Alex Rivera | Logout

How to check Oracle database for long running queries

Asked 2009-03-07T18:43:40.247
112

My application, which uses an Oracle database, is going slow or appears to have stopped completely.

How can find out which queries are most expensive, so I can investigate further?

Edit
Report

1 Answer

41

Try this, it will give you queries currently running for more than 60 seconds. Note that it prints multiple lines per running query if the SQL has multiple lines. Look at the sid,serial# to see what belongs together.

select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s 
join v$sqltext_with_newlines q
on s.sql_address = q.address
 where status='ACTIVE'
and type <>'BACKGROUND'
and last_call_et> 60
order by sid,serial#,q.piece
answered 2009-03-07T19:03:25.223

Your Answer