如何找出消耗資源的sql語句

2021-09-01 21:56:23 字數 1075 閱讀 1615

--cpu高的sql

select sql_text from v$sql order by cpu_time desc

--邏輯讀多的sql:

select * from (select buffer_gets, sql_text

from v$sqlarea

where buffer_gets > 500000

order by buffer_gets desc) where rownum<=30;

--執行次數多的sql :

select sql_text,executions from

(select sql_text,executions from v$sqlarea order by executions desc)

where rownum<81;

--讀硬碟多的sql :

select sql_text,disk_reads from

(select sql_text,disk_reads from v$sqlarea order by disk_reads desc)

where rownum<21;

--排序多的sql :

select sql_text,sorts from

(select sql_text,sorts from v$sqlarea order by sorts desc)

where rownum<21;

--cpu消耗高,如果確認是oracle程序做的

--那麼直接在os上抓到消耗cpu的pid,然後查出是哪個session,找出相應的sql

@getsqlbypid

select sql_text from v$sqltext where hash_value = (

select sql_hash_value from v$session where sid = (

select s.sid from

v$session s, v$process p

where p.addr = s.paddr

and p.spid = &ospid

))order by piece;

如何查詢消耗資源較大的SQL

對於優化來講,查詢消耗資源較大的sql至關重要,下面介紹幾個之前用到的sql。1.從v sqlarea中查詢最占用資源的查詢。1 select b.username username,a.disk reads reads,2 a.executions exec,a.disk reads decode...

如何查詢消耗資源較大的SQL

對於優化來講,查詢消耗資源較大的sql至關重要,下面介紹幾個之前用到的sql。1.從v sqlarea中查詢最占用資源的查詢。select b.username username,a.disk reads reads,a.executions exec,a.disk reads decode a.e...

oracle 實時查詢消耗資源SQL

1.先通過top命令檢視產用資源較多的pid號,注意 top命令的user的oacle的,關注pid 2.查詢當前耗時的會話id,使用者名稱,sqlid等 其中top中的pid就是v process的spid字段值。不是v process檢視中的pid值。select sid,serial mach...