How to check Oracle database for long running queries

前端 未结 8 1804
半阙折子戏
半阙折子戏 2020-12-02 04:03

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 inves

8条回答
  •  孤街浪徒
    2020-12-02 04:50

    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
    

提交回复
热议问题