如何监控一个sql每天执行了多久,开始时间和结束时间,通过某些视图去查询,不是去分析sqllog日志。我试着通过V$SESSIONS可以查到,开始时间,但是结束就没有了,得一直盯着。
select sql_id,sess_id,trx_id,top_sql_text,start_time,trunc(time_used/1000/1000.0,2) as time_used_s,n_logic_read,n_phy_read,affected_rows,hard_parse_flag
from V$SQL_HISTORY
where top_sql_text like 'call dbms_lock.sleep(3)%'
order by 4 desc;
SELECT * from SYS.V$SQL_HISTORY;
