[20191223]Wait for Java.txt
[20191223]Wait for Java.txt
--//連結:重複測試.
1.環境:
@ ver1
2.測試指令碼:
--//java_wait_for_cpu.sql
rem
rem Script: java_wait_for_cpu.sql
rem Author: Jonathan Lewis
rem Dated: Nov 2019
rem
rem Last tested
rem 19.3.0.0
rem 12.2.0.1
rem
rem Based on an email from Jack van Zanen to Oracle-L
rem
set time on
create or replace procedure milli_sleep(i_milliseconds in number)
as
language java
name 'java.lang.Thread.sleep(int)';
/
set pagesize 60
set linesize 132
set trimspool on
column sample_time format a32
column event format a32
column sql_text format a60
column sql_id new_value m_sql_id
set echo on
execute milli_sleep(1e4)
select
sample_time, sample_id, session_state, sql_id, event
from
v$active_session_history
where
session_id = sys_context('userenv','sid')
and sample_time > sysdate - 1/1440
order by
sample_time
;
select sql_id, round(cpu_time/1e6,3) cpu_time, round(elapsed_time/1e6,3) elapsed, sql_text from v$sql where sql_id = '&m_sql_id';
--//輸出如下:
SCOTT@book> @ n1.txt
Procedure created.
08:52:41 SCOTT@book> execute milli_sleep(1e4)
PL/SQL procedure successfully completed.
08:52:52 SCOTT@book>
08:52:52 SCOTT@book> select
08:52:52 2 sample_time, sample_id, session_state, sql_id, event
08:52:52 3 from
08:52:52 4 v$active_session_history
08:52:52 5 where
08:52:52 6 session_id = sys_context('userenv','sid')
08:52:52 7 and sample_time > sysdate - 1/1440
08:52:52 8 order by
08:52:52 9 sample_time
08:52:52 10 ;
SAMPLE_TIME SAMPLE_ID SESSION SQL_ID EVENT
-------------------------------- ---------- ------- ------------- --------------------------------
2019-12-23 08:52:42.545 5076973 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:43.555 5076974 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:44.555 5076975 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:45.555 5076976 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:46.555 5076977 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:47.555 5076978 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:48.555 5076979 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:49.555 5076980 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:50.555 5076981 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:51.565 5076982 ON CPU 4tbmywxw2ndt1
2019-12-23 08:52:52.565 5076983 ON CPU 6tp6b74pup4jw
11 rows selected.
08:52:52 SCOTT@book>
08:52:52 SCOTT@book> select sql_id, round(cpu_time/1e6,3) cpu_time, round(elapsed_time/1e6,3) elapsed, sql_text from v$sql where sql_id = '&m_sql_id';
old 1: select sql_id, round(cpu_time/1e6,3) cpu_time, round(elapsed_time/1e6,3) elapsed, sql_text from v$sql where sql_id = '&m_sql_id'
new 1: select sql_id, round(cpu_time/1e6,3) cpu_time, round(elapsed_time/1e6,3) elapsed, sql_text from v$sql where sql_id = '6tp6b74pup4jw'
SQL_ID CPU_TIME ELAPSED SQL_TEXT
------------- ---------- ---------- ------------------------------------------------------------
6tp6b74pup4jw .04 .04 select sample_time, sample_id, session_state, sql_id
, event from v$active_session_history where
session_id = sys_context('userenv','sid') and sample_tim
e > sysdate - 1/1440 order by sample_time
--//最後的輸出有點問題:
08:52:52 SCOTT@book> select sql_id, round(cpu_time/1e6,3) cpu_time, round(elapsed_time/1e6,3) elapsed, sql_text from v$sql where sql_id = '4tbmywxw2ndt1';
SQL_ID CPU_TIME ELAPSED SQL_TEXT
------------- ---------- ---------- ------------------------------------------------------------
4tbmywxw2ndt1 .222 10.656 BEGIN milli_sleep(1e4); END;
--//可以發現CPU_TIME僅僅消耗.222.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2669918/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【go語言】wait,wait for meGoAI
- wait() vs sleep()AI
- [20191223]關於共享記憶體段相關問題3.txt記憶體
- Golang CLOSE WAIT 分析GolangAI
- Oracle RAC Wait EventsOracleAI
- 【YashanDB知識庫】YAS-02024 lock wait timeout, wait time 0 millisecondsAI
- sleep()和wait()區別AI
- 10.25 V$SESSION_WAITSessionAI
- cursor pin S wait on XAI
- Oracle Enqueues Wait Events 二OracleENQAI
- Oracle Enqueues Wait Events 一OracleENQAI
- Oracle Enqueues Wait Events 三OracleENQAI
- cursor: pin S wait on XAI
- MXNet: wait_to_read 方法AI
- 調整time_waitAI
- TCP連線的TIME_WAIT和CLOSE_WAIT 狀態解說TCPAI
- 10.27 V$SESSION_WAIT_HISTORYSessionAI
- 10.26 V$SESSION_WAIT_CLASSSessionAI
- socket close和shutdown的區別,TIME_WAIT和CLOSE_WAIT,SO_REUSEADDRAI
- Lock wait timeout exceeded; try restarting transactionAIREST
- mysql MASTER_POS_WAIT函式MySqlASTAI函式
- session檢視中wait_timeSessionAI
- 阻塞程式函式 wait()和waitpid()函式AI
- 聊聊select, poll 和 epoll_waitAI
- MySQL中wait_timeout的坑MySqlAI
- wait()方法與await()方法的區別AI
- cursor:pin S wait on X故障診分析AI
- Java-併發-wait()、notify()和notifyAll()JavaAI
- MySQL更新卡住報錯lock wait timeoutMySqlAI
- SharePlex reader missed marker wait for xx but got xxAIGo
- 【WAIT】 log file sync等待事件說明AI事件
- stored procedure 收集session wait 資訊(轉)SessionAI
- Java 中的 Wait 和 Notify 機制JavaAI
- [20210527]關於v$wait_chain.txtAI
- axios.get (url).wait (loadingGif, functionOk, functionErr)iOSAIFunction
- buffer busy wait 等待事件說明(轉)AI事件
- 大量time-wait的處理方法AI
- 【Java】sleep和wait區別總結JavaAI