zoukankan      html  css  js  c++  java
  • 通过performance schema收集慢查询

    MySQL5.6起performance schema自动开启,里面涉及记录 statement event的表

    mysql> show tables like '%statement%';
    +----------------------------------------------------+
    | Tables_in_performance_schema (%statement%)         |
    +----------------------------------------------------+
    | events_statements_current                          |
    | events_statements_history                          |
    | events_statements_history_long                     |
    | events_statements_summary_by_account_by_event_name |
    | events_statements_summary_by_digest                |
    | events_statements_summary_by_host_by_event_name    |
    | events_statements_summary_by_program               |
    | events_statements_summary_by_thread_by_event_name  |
    | events_statements_summary_by_user_by_event_name    |
    | events_statements_summary_global_by_event_name     |
    | prepared_statements_instances                      |
    +----------------------------------------------------+
    11 rows in set (0.00 sec)

    statement event 的设置 

    详细参考官方文档:https://dev.mysql.com/doc/refman/5.6/en/performance-schema-statement-tables.ht

    server端发生的所有的statement都会记录,当前未结束的会话发生的statement记录在表events_statements_current,已结束的会话线程发生的statement记录在events_statements_history,此表有大小限制,默认是100,达到限制会删除老的statement

    设置记录哪些类型的statement,默认设置为所有的类型

    mysql> SELECT * FROM setup_instruments WHERE NAME LIKE 'statement/%';
    +---------------------------------------------+---------+-------+
    | NAME                                        | ENABLED | TIMED |
    +---------------------------------------------+---------+-------+
    | statement/sql/select                        | YES     | YES   |
    | statement/sql/create_table                  | YES     | YES   |
    | statement/sql/create_index                  | YES     | YES   |
    ...
    | statement/sp/stmt                           | YES     | YES   |
    | statement/sp/set                            | YES     | YES   |
    | statement/sp/set_trigger_field              | YES     | YES   |
    | statement/scheduler/event                   | YES     | YES   |
    | statement/com/Sleep                         | YES     | YES   |
    | statement/com/Quit                          | YES     | YES   |
    | statement/com/Init DB                       | YES     | YES   |
    ...
    | statement/abstract/Query                    | YES     | YES   |
    | statement/abstract/new_packet               | YES     | YES   |
    | statement/abstract/relay_log                | YES     | YES   |
    +---------------------------------------------+---------+-------+

    关于对statement event相关表的设置,MySQL5.6 默认events_statements_history关闭,MySQL5.7开启

    mysql> SELECT * FROM setup_consumers WHERE NAME LIKE '%statements%';
    +--------------------------------+---------+
    | NAME                           | ENABLED |
    +--------------------------------+---------+
    | events_statements_current      | YES     |
    | events_statements_history      | NO      |
    | events_statements_history_long | NO      |
    | statements_digest              | YES     |
    +--------------------------------+---------+

    如果通过pmm来收集慢查询,其查询的是表events_statements_history_long,MySQL5.6需要启用此表

    启用events_statements_history

    UPDATE setup_consumers SET ENABLED = 'NO'
    WHERE NAME LIKE 'events_statements_history';
     
  • 相关阅读:
    解决 搭建Jekins过程中 启动Tomcat的java.net.UnknownHostException异常
    射手和农场主
    java 和 JS(javaScript)中的反斜杠正则转义
    分享修改密码的SharePoint Web part: ITaCS Change Password web part
    分享微软官方Demo用的SharePoint 2010, Exchange 2010, Lync 2010虚拟机
    Office 365 的公共网站的一些限制及解决的办法
    SharePoint 2013 关闭 customErrors
    安装 KB2844286 导致SharePoint 2010 XSLT web part 显示出现错误
    安装Office Web Apps Server 2013 – KB2592525安装失败
    如何将hyper-v虚拟机转换成vmware的虚拟机- 转换SharePoint 2010 Information Worker Demonstration and Evaluation Virtual Machine (SP1)
  • 原文地址:https://www.cnblogs.com/Bccd/p/8331405.html
Copyright © 2011-2022 走看看