监控sql执行时剩余时间
2014-10-30 14:29
281 查看
--监控sql执行时剩余时间 你知道正在运行的sql大概需要多长时间么? 你知道正在运行的sql大概完成了百分之几么? 你知道正在运行的sql大概还要多长时间完成么? V$SESSION_LONGOPS帮你忙。 V$SESSION_LONGOPS在<span style="font-family: Arial, Helvetica, sans-serif;">官方文档中的描述:</span> V$SESSION_LONGOPS displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution, and more operations are added for every Oracle release. To monitor query execution progress, you must be using the cost-based optimizer and you must: Set the TIMED_STATISTICS or SQL_TRACE parameters to true Gather statistics for your objects with the DBMS_STATS package --意义: 统计各个操作时间大于6s的语句 --前提条件: 基于成本的优化器cbo TIMED_STATISTICS或SQL_TRACE为true 对象有统计信息 测试: select * from v$version; --Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi select * from v$parameter where name like '%timed_statistics%' VALUE TRUE select last_analyzed from user_tables where table_name='LHJ_1G' LAST_ANALYZED 2013-12-10 PM 01:19:36 --session1: drop table t; create table t as select * from lhj_1g; --session2: select a.username, a.target, a.sid, a.SERIAL#, a.opname, round(a.sofar * 100 / a.totalwork, 0) || '%' as progress, --进度条 time_remaining second, --剩余时间:秒 trunc(a.time_remaining / 60, 2) minute,--剩余时间:分钟 b.sql_text, b.LAST_ACTIVE_TIME from v$session_longops a, v$sqlarea b where a.time_remaining <> 0 and a.sql_address = b.address and a.sql_hash_value = b.hash_value and a.username = 'GGS'
过一会再重复执行上面语句:
sql语句执行完成或者取消后,以上查询为空
相关文章推荐
- 监控SQL:执行表中所有sql语句、记录每个语句运行时间(3)
- JAMon监控SQL执行时间
- 监控sql语句执行时间
- 监控sql执行时间
- 监控sql运行时剩余时间
- 基于spring,mybatis的监控sql执行时间
- 判断sql执行所花的时间(精度为毫秒)
- 计算sql语句的执行时间
- 统计sql语句执行时间
- 监控函数的执行时间,若超时则强制返回一个默认值
- 在性能测试时,如何观察服务器端Oracle在执行的Sql语句【监控】
- 获得sql 语句执行时间
- 监控程序执行效率,页面执行时间
- 得到SQL语句执行时间
- SQL语句执行时间
- sqlserver中获取执行sql语句时间的方法
- 用jamon来监控你的sql执行效率
- MSSQL中获得SQL语句的执行时间。
- csdn摘录-sql 执行时间,sql导出查询数据到Excel...
- 测试SQL语句执行时间