監控sql執行時剩餘時間,監控sql剩餘時間

來源:互聯網
上載者:User

監控sql執行時剩餘時間,監控sql剩餘時間

--監控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 trueGather statistics for your objects with the DBMS_STATS package--意義:統計各個操作時間大於6s的語句--前提條件:基於成本的最佳化器cboTIMED_STATISTICS或SQL_TRACE為true對象有統計資訊測試:select * from v$version;--Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64biselect * from v$parameter where name like '%timed_statistics%'VALUETRUEselect last_analyzed from user_tables where table_name='LHJ_1G'LAST_ANALYZED2013-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執行的效率?用什工具?怎監控?

用sqlServer內建的sql server profiler

可以監視sql執行的cpu佔用率,執行時間長度等
 
oracle 中怎監控sql執行的進度?

pl/sql tool session 找到相應的session 一般應用程式是 JDBC Thin Client 然後點下面的sqltext就可以看到執行到那句話了,可以不停重新整理看sql變化
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.