在Oracle Enterprise Edition - Version: 11.1.0.6之后,有一个新特性允许我们监控long running sql。
real time sql monitoring,这个特性只有设置一下参数:
statisitcs_level = TYPICAL or ALL
control_management_pack_access = DIAGNOSTIC+TUNING
才生效,并且long running sql处于并行执行或者消耗CPU资源超过5s,就会自动开启。
一,hint
MONITOR : 强制监视sql执行
NO_MONITOR :防止sql被监视
二,V$SQL_MONITOR and V$SQL_PLAN_MONITOR
V$SQL_MONITOR的信息每s刷新,当sql执行完毕,信息并不立即删除而是保持至少一分钟。
KEY NUMBER:可以和存储在V$SQL_PLAN_MONITOR的相关执行计划信息关联 .
STATUS : SQL执行状态:
EXECUTING - SQL is executing
DONE (ERROR) - Execution terminated with an error
DONE (FIRST N ROWS) - Execution terminated by the application before all rows were fetched
DONE (ALL ROWS) - Execution terminated and all rows were fetched
DONE - Execution terminated (parallel execution)
三,测试