程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> oracle優化輔助SQL語句

oracle優化輔助SQL語句

編輯:Oracle教程

oracle優化輔助SQL語句


--查詢正在執行的SQL語句
SELECT OSUSER 電腦登錄身份, 
PROGRAM 發起請求的程序, 
USERNAME 登錄系統的用戶名, 
SCHEMANAME, 
B.Cpu_Time 花費cpu的時間, 
STATUS, 
B.SQL_TEXT 執行的sql,
B. 
FROM V$SESSION A 
LEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS 
AND A.SQL_HASH_VALUE = B.HASH_VALUE 
ORDER BY b.cpu_time DESC;

 


--查詢比較耗CPU的SQL語句
select *
from (select v.sql_id,
v.child_number,
v.sql_text,
v.elapsed_time,
v.cpu_time,
v.disk_reads,
rank() over(order by v.cpu_time desc) elapsed_rank
from v$sql v) a
where elapsed_rank <= 10;

 


--查詢比較耗磁盤的SQL語句

select * from (select v.sql_id,
v.child_number, v.sql_text, 
v.elapsed_time, v.cpu_time, 
v.disk_reads, 
rank() over(order by v.disk_reads desc) elapsed_rank 
from v$sql v) a where elapsed_rank <= 10;

 

--查詢比較慢的SQL語句

select * from (
select parsing_user_id,executions,sorts
command_type,disk_reads,sql_text from v$sqlarea order by disk_reads desc
)where rownum<10

 


--Oracle 對未提交事務的查詢

select a.sid,a.blocking_session,a.last_call_et,a.event,
object_name,
dbms_rowid.rowid_create(1,data_object_id,rfile#,ROW_WAIT_BLOCK#,ROW_WAIT_ROW#) "rowid" ,
c.sql_text,c.sql_fulltext
from v$session a,v$sqlarea c ,dba_objects,v$datafile
where a.blocking_session is not null
and a.sql_hash_value = c.hash_value 
and ROW_WAIT_OBJ#=object_id and file#=ROW_WAIT_FILE#;

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved