sql_monitor實時監控

1 檢查數據庫是否啓用了監控功能sql

1)檢查參數:CONTROL_MANAGEMENT_PACK_ACCES數據庫

SQL> show parameter CONTROL_MANAGEMENT_PACK_ACCESS;ide

NAME                                 TYPE        VALUEblog

------------------------------------ ----------- ------------------------------string

control_management_pack_access       string      DIAGNOSTIC+TUNINGit

 

備註:參數值爲「DIAGNOSTIC+TUNING」表示SQL 監控啓用io

 

2)檢查參數:statistic監控

SQL> show parameter statisticmodule

NAME                                 TYPE        VALUEcli

------------------------------------ ----------- ------------------------------

optimizer_use_pending_statistics     boolean     FALSE

statistics_level                     string      TYPICAL

timed_os_statistics                  integer     0

timed_statistics                     boolean     TRUE

備註:實時 SQL 監控須要 statistics_level 初始化參數設置爲 TYPICAL 或 ALL

2 模擬一個大查詢

表gl_je_lines中有120620495條數據,本地查詢時間爲12.31min

SQL> select count(1) from gl_je_lines gjh;

120620495

 

3 生成sql_monitor報告

注:主要由SQL的SQL_ID,就能夠生成sql_monitor報表

1)獲取SQL的SQL_ID

select sm.status,

       sm.username,

       sm.module,

       sm.program,

       (select fcp.user_concurrent_program_name

        from fnd_concurrent_programs_vl fcp

       where fcp.concurrent_program_name  =  sm.module) 請求名稱,

       sm.physical_read_bytes / 1024 / 1024 read_io_mb,

       sm.io_interconnect_bytes / 1024 / 1024 read_io_inter_mb,

       sm.*,

       sm.sid,

       sm.client_identifier,

       sm.sql_id,

       sm.sql_text

  from v$sql_monitor sm

 where 1 = 1

   and sm.username = 'APPS'

 --  and sm.module = 'PL/SQL Developer'

 --  and sm.program = 'plsqldev.exe'

 order by sm.physical_read_bytes desc;

獲得SQL_ID:5rw111jmvv6xk

 

2)生成報告(模式:TEXT、HTML、XML、ACTIVE)

A 文本格式報告

select dbms_sqltune.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT') as report

  from dual;

注:輸入前面查到的SQL_ID值,獲得以下sql_monitor監控報告:

 

 

B HTML格式

select dbms_sqltune.report_sql_monitor(sql_id       => '&sqlid',

                                       report_level => 'ALL',

                                       type         => 'HTML') comm

  from dual;

注:輸入前面查到的SQL_ID值,獲得以下sql_monitor監控報告:

 

相關文章
相關標籤/搜索