zoukankan      html  css  js  c++  java
  • sql_monitor实时监控

    1 检查数据库是否启用了监控功能

    1)检查参数:CONTROL_MANAGEMENT_PACK_ACCES

    SQL> show parameter CONTROL_MANAGEMENT_PACK_ACCESS;

    NAME                                 TYPE        VALUE

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

    control_management_pack_access       string      DIAGNOSTIC+TUNING

    备注:参数值为“DIAGNOSTIC+TUNING”表示SQL 监控启用

    2)检查参数:statistic

    SQL> show parameter statistic

    NAME                                 TYPE        VALUE

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

    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监控报告:

     

  • 相关阅读:
    python3中模块初识
    Django 应用程序 + 模型 + 基本数据访问
    Axure文本框验证和外部url的调用
    MATLAB 实时脚本(live-script)使用
    Django MTV 开发模式 + 数据库配置
    Django 模板继承
    Django 修改视图文件(views.py)并加载Django模块 + 利用render_to_response()简化加载模块 +locals()
    Django Context对象 + 过滤器 + 标签
    Axure 页面内多组内容切换的实现 + 利用一个内联框架实现百度地图访问
    MATLAB绘图功能(2) 二维底层绘图修饰
  • 原文地址:https://www.cnblogs.com/hand-lzs/p/9221204.html
Copyright © 2011-2022 走看看