列出oracle dbtime得sql語句
可以根據dbtime 檢視資料庫得繁忙程度,獲取某個快照得awr報告,進行分析
----------------------------------------------------------------------------------------
--
-- File name: dbtime.sql
-- Purpose: Find busiest time periods in AWR.
-
-- Author: Kerry Osborne
--
-- Usage: This scripts prompts for three values, all of which can be left blank.
--
-- instance_number: set to limit to a single instance in RAC environment
--
-- begin_snap_id: set it you want to limit to a specific range, defaults to 0
--
-- end_snap_id: set it you want to limit to a specific range, defaults to 99999999
--
--
---------------------------------------------------------------------------------------
set lines 155
col dbtime for 999,999.99
col begin_timestamp for a40
select * from (
select begin_snap, end_snap, timestamp begin_timestamp, inst, a/1000000/60 DBtime from
(
select
e.snap_id end_snap,
lag(e.snap_id) over (order by e.snap_id) begin_snap,
lag(s.end_interval_time) over (order by e.snap_id) timestamp,
s.instance_number inst,
e.value,
nvl(value-lag(value) over (order by e.snap_id),0) a
from dba_hist_sys_time_model e, DBA_HIST_SNAPSHOT s
where s.snap_id = e.snap_id
and e.instance_number = s.instance_number
and to_char(e.instance_number) like nvl('&instance_number',to_char(e.instance_number))
and stat_name = 'DB time'
)
where begin_snap between nvl('&begin_snap_id',0) and nvl('&end_snap_id',99999999)
and begin_snap=end_snap-1
order by dbtime desc
)
where rownum < 31
/
BEGIN_SNAP END_SNAP BEGIN_TIMESTAMP INST DBTIME
---------- ---------- ---------------------------------------- ---------- -----------
99 100 02-MAY-18 04.00.11.163 PM 1 2,791.85
80 81 01-MAY-18 09.00.01.121 PM 1 2,749.62
66 67 01-MAY-18 07.00.08.007 AM 1 2,733.33
67 68 01-MAY-18 08.00.21.814 AM 1 2,732.78
57 58 30-APR-18 10.00.06.732 PM 1 2,728.00
56 57 30-APR-18 09.00.35.565 PM 1 2,727.69
65 66 01-MAY-18 06.00.00.538 AM 1 2,726.59
72 73 01-MAY-18 01.00.30.321 PM 1 2,723.55
100 101 02-MAY-18 05.00.27.047 PM 1 1,764.40
55 56 30-APR-18 08.00.13.544 PM 1 1,706.66
59 60 01-MAY-18 12.00.17.902 AM 1 1,704.93
BEGIN_SNAP END_SNAP BEGIN_TIMESTAMP INST DBTIME
---------- ---------- ---------------------------------------- ---------- -----------
64 65 01-MAY-18 05.00.19.310 AM 1 1,703.53
83 84 02-MAY-18 12.00.44.286 AM 1 1,702.55
85 86 02-MAY-18 02.00.11.423 AM 1 1,701.95
69 70 01-MAY-18 10.00.21.811 AM 1 1,675.91
77 78 01-MAY-18 06.00.37.335 PM 1 1,675.91
71 72 01-MAY-18 12.00.16.844 PM 1 1,675.83
52 53 30-APR-18 05.00.02.455 PM 2 1,109.93
101 102 02-MAY-18 06.00.39.504 PM 2 1,088.41
86 87 02-MAY-18 03.00.24.853 AM 2 1,049.19
53 54 30-APR-18 06.00.12.352 PM 2 1,036.89
44 45 30-APR-18 09.00.00.954 AM 2 1,026.10
BEGIN_SNAP END_SNAP BEGIN_TIMESTAMP INST DBTIME
---------- ---------- ---------------------------------------- ---------- -----------
51 52 30-APR-18 04.00.25.353 PM 2 1,017.33
50 51 30-APR-18 03.00.11.207 PM 2 1,003.77
45 46 30-APR-18 10.00.12.054 AM 2 1,003.51
47 48 30-APR-18 12.00.02.027 PM 2 1,002.93
46 47 30-APR-18 11.00.29.502 AM 2 1,002.87
48 49 30-APR-18 01.00.12.856 PM 2 1,002.62
49 50 30-APR-18 02.00.10.611 PM 2 1,002.43
43 44 30-APR-18 08.00.29.126 AM 2 880.34
----------------------------------------------------------------------------------------
--
-- File name: dbtime.sql
-- Purpose: Find busiest time periods in AWR.
-
-- Author: Kerry Osborne
--
-- Usage: This scripts prompts for three values, all of which can be left blank.
--
-- instance_number: set to limit to a single instance in RAC environment
--
-- begin_snap_id: set it you want to limit to a specific range, defaults to 0
--
-- end_snap_id: set it you want to limit to a specific range, defaults to 99999999
--
--
---------------------------------------------------------------------------------------
set lines 155
col dbtime for 999,999.99
col begin_timestamp for a40
select * from (
select begin_snap, end_snap, timestamp begin_timestamp, inst, a/1000000/60 DBtime from
(
select
e.snap_id end_snap,
lag(e.snap_id) over (order by e.snap_id) begin_snap,
lag(s.end_interval_time) over (order by e.snap_id) timestamp,
s.instance_number inst,
e.value,
nvl(value-lag(value) over (order by e.snap_id),0) a
from dba_hist_sys_time_model e, DBA_HIST_SNAPSHOT s
where s.snap_id = e.snap_id
and e.instance_number = s.instance_number
and to_char(e.instance_number) like nvl('&instance_number',to_char(e.instance_number))
and stat_name = 'DB time'
)
where begin_snap between nvl('&begin_snap_id',0) and nvl('&end_snap_id',99999999)
and begin_snap=end_snap-1
order by dbtime desc
)
where rownum < 31
/
BEGIN_SNAP END_SNAP BEGIN_TIMESTAMP INST DBTIME
---------- ---------- ---------------------------------------- ---------- -----------
99 100 02-MAY-18 04.00.11.163 PM 1 2,791.85
80 81 01-MAY-18 09.00.01.121 PM 1 2,749.62
66 67 01-MAY-18 07.00.08.007 AM 1 2,733.33
67 68 01-MAY-18 08.00.21.814 AM 1 2,732.78
57 58 30-APR-18 10.00.06.732 PM 1 2,728.00
56 57 30-APR-18 09.00.35.565 PM 1 2,727.69
65 66 01-MAY-18 06.00.00.538 AM 1 2,726.59
72 73 01-MAY-18 01.00.30.321 PM 1 2,723.55
100 101 02-MAY-18 05.00.27.047 PM 1 1,764.40
55 56 30-APR-18 08.00.13.544 PM 1 1,706.66
59 60 01-MAY-18 12.00.17.902 AM 1 1,704.93
BEGIN_SNAP END_SNAP BEGIN_TIMESTAMP INST DBTIME
---------- ---------- ---------------------------------------- ---------- -----------
64 65 01-MAY-18 05.00.19.310 AM 1 1,703.53
83 84 02-MAY-18 12.00.44.286 AM 1 1,702.55
85 86 02-MAY-18 02.00.11.423 AM 1 1,701.95
69 70 01-MAY-18 10.00.21.811 AM 1 1,675.91
77 78 01-MAY-18 06.00.37.335 PM 1 1,675.91
71 72 01-MAY-18 12.00.16.844 PM 1 1,675.83
52 53 30-APR-18 05.00.02.455 PM 2 1,109.93
101 102 02-MAY-18 06.00.39.504 PM 2 1,088.41
86 87 02-MAY-18 03.00.24.853 AM 2 1,049.19
53 54 30-APR-18 06.00.12.352 PM 2 1,036.89
44 45 30-APR-18 09.00.00.954 AM 2 1,026.10
BEGIN_SNAP END_SNAP BEGIN_TIMESTAMP INST DBTIME
---------- ---------- ---------------------------------------- ---------- -----------
51 52 30-APR-18 04.00.25.353 PM 2 1,017.33
50 51 30-APR-18 03.00.11.207 PM 2 1,003.77
45 46 30-APR-18 10.00.12.054 AM 2 1,003.51
47 48 30-APR-18 12.00.02.027 PM 2 1,002.93
46 47 30-APR-18 11.00.29.502 AM 2 1,002.87
48 49 30-APR-18 01.00.12.856 PM 2 1,002.62
49 50 30-APR-18 02.00.10.611 PM 2 1,002.43
43 44 30-APR-18 08.00.29.126 AM 2 880.34
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30345407/viewspace-2153683/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle基本SQL語句OracleSQL
- SQL查詢語句 (Oracle)SQLOracle
- Oracle SQL精妙SQL語句講解OracleSQL
- 後臺執行SQL語句(oracle)SQLOracle
- 【SQL】Oracle SQL join on語句and和where使用區別SQLOracle
- java連線oracle執行sql語句JavaOracleSQL
- mybatis 得sql語句對應簡單型別MyBatisSQL型別
- mysql 索引巧用,SQL語句寫得忒野了MySql索引
- Oracle執行語句跟蹤 使用sql trace實現語句追蹤OracleSQL
- Java中如何解析SQL語句、格式化SQL語句、生成SQL語句?JavaSQL
- SQL語句SQL
- Oracle資料庫SQL語句執行過程Oracle資料庫SQL
- 18 與Oracle Data Guard 相關的SQL語句OracleSQL
- 【TUNE_ORACLE】列出索引被哪些SQL引用的SQL參考Oracle索引SQL
- 【SQL】9 SQL INSERT INTO 語句SQL
- 【SQL】10 SQL UPDATE 語句SQL
- 【SQL】11 SQL DELETE 語句SQLdelete
- SQL SELECT 語句SQL
- sql常用語句SQL
- 【SQL】Oracle sql語句 minus函式執行效率與join對比SQLOracle函式
- ORACLE常用語句:Oracle
- Oracle OCP(01):使用SQL SELECT語句檢索資料OracleSQL
- oracle v$sqlare 分析SQL語句使用資源情況OracleSQL
- ORACLE中sql語句----運算子的優先順序OracleSQL
- oracle常用後臺程序及sql語句執行流程OracleSQL
- 【SQL】Oracle BLOB 批量匯入匯出圖片語句SQLOracle
- 6. Oracle開發和應用—6.3. 基本SQL語句—6.3.4. select語句OracleSQL
- 【TUNE_ORACLE】列出走了Filter的SQL參考OracleFilterSQL
- 查詢Oracle正在執行的sql語句及執行該語句的使用者OracleSQL
- 獲取oracle sql語句詳細些執行計劃OracleSQL
- Oracle行轉列、列轉行的Sql語句總結OracleSQL
- 【TUNE_ORACLE】查出所有有“select *”語句的SQL參考OracleSQL
- oracle資料庫檢視鎖表的sql語句整理Oracle資料庫SQL
- 1.3. SQL 語句SQL
- Sql語句小整理SQL
- SQL語句優化SQL優化
- SQL語句IN的用法SQL
- SQL 語句學習SQL