ORACLE 查詢SQL執行時間

2021-10-02 06:45:04 字數 1097 閱讀 7002

select 

c.sample_time 執行時間,

a.elapsed_time_delta / 1000000 "執行耗時(s)",

b.sql_text sql文字,

to_char(substr(b.sql_text,1,400)) sql文字擷取

from dba_hist_sqlstat a

left join dba_hist_sqltext b on a.sql_id = b.sql_id

left join dba_hist_active_sess_history c on c.sql_id = b.sql_id

where parsing_schema_name= 'scott'/*使用者名稱(大寫)*/ and c.sample_time is not null

order by c.sample_time desc;

或者

select a.sql_id,b.begin_interval_time 執行時間,b.startup_time,

a.elapsed_time_delta/1000000 "執行耗時(s)",

t3.sql_text sql文字,

to_char(substr(t3.sql_text,1,400)) sql文字擷取

from dba_hist_sqlstat a

left join dba_hist_snapshot b on a.snap_id = b.snap_id

left join dba_hist_sqltext t3 on a.sql_id = t3.sql_id

where parsing_schema_name= 'scott'/*使用者名稱(大寫)*/

order by begin_interval_time desc;

結果如下:

dba_hist_sqlstat 及問題語句分析:

參考:oracle查詢sql語句執行的耗時和執行時間 

獲取sql執行時間

sql server中獲取要執行的sql或sql塊的執行時間,方法之一如下 declare begin datetime,end datetime set begin getdate your sql set end getdate print datediff millisecond,begin,...

獲取sql執行時間

sql server中獲取要執行的sql或sql塊的執行時間,方法之一如下 declare begin datetime,end datetime set begin getdate your sql set end getdate print datediff millisecond,begin,...

獲取sql執行時間

sql server中獲取要執行的sql或sql塊的執行時間,方法之一如下 declare begin datetime,end datetime set begin getdate your sql set end getdate print datediff millisecond,begin,...