V$SESSION_LONGOPS

V$SESSION_LONGOPS视图记录了执行时间长于6秒的某个操作(这些操作可能是备份,恢复,Hash Join,Sort ,Nested loop,Table Scan, Index Scan 等等)。

要想V$SESSION_LONGOPS视图中有记录

1.必须将初始化参数 timed_statistics设置为true或者开启sql_trace

2.必须用ANALYZE或者DBMS_STATS对对象收集过统计信息

要理解的就是:比如某个SQL语句执行时间比较长,但是每个操作都没有超过6秒钟,那么你在V$SESSION_LONGOPS这个视图中就无法查询到该信息。还有一点就是,即使某个操作完成了,你在该视图中也可能查询到该操作依然记录在视图中。

这个视图通常用来分析SQL运行缓慢的原因,配合V$SESSION视图。

下面的查询显示未完成操作的信息

col start_time format a20

col last_update_time a30

select sid,message, start_time,last_update_time,time_remaining,

elapsed_seconds from V$SESSION_LONGOPS where time_remaining>0;

如果是RAC:

col start_time format a20

col last_update_time a30

select inst_id,sid,message, start_time,last_update_time,time_remaining,

elapsed_seconds from GV$SESSION_LONGOPS where time_remaining>0;

原文地址:https://www.cnblogs.com/hehe520/p/6330596.html