• mysql sys schema 案例两则


    #######sample 1

    https://www.percona.com/blog/2015/09/16/webinar-introduction-mysql-sys-schema-follow-questions/

    Thanks to all who attended my webinar Introduction to MySQL SYS Schema. This blog is for me to address the extra questions I didn’t have time to answer on the stream.

    Can i have the performance_schema enabled in 5.6 and then install the sys schema? Or they are one and the same?

    You need to have enabled the performance_schema in order to use it through the sys schema. They are different entities. In general, performance_schema collects and stores the data, and sys schema reads and presents the data.

    The installation of sys schema on primary database will be replicated to the slaves?

    By default, no. If you wish that the Sys Schema replicates to the slaves, you can modify the before_setup.sql (https://github.com/MarkLeith/mysql-sys/blob/master/before_setup.sql#L18) to skip the “SET sql_log_bin = 0;

    Can MySQL save the slow running query in any table?

    Yes it does: https://dev.mysql.com/doc/refman/5.6/en/log-destinations.html

    How to see the query execution date & time from events_statements_current/history views in performance_schema?

    You can check the performance_schema.events_statements_summary_by_digest table, that have the fields FIRST_SEEN and LAST_SEEN which are both a datetime values.

    When the Sys Schema views show certain stats for the queries, is there a execution time range for queries under evaluation or is it like all the queries executed until date?

    It’s all the queries executed until date, except when using some of the stored procedures that receive as a parameter a run time value, like “diagnostics” or “ps_trace_statement_digest”

    I want to write the automated script to rebuild table or index. How to determine which table(s) or index(es) need to be rebuilt because of high fragmentation ratio?

    For this you need to use something completely different. To know the fragmentation inside an InnoDB table i’ll recommend you to use XtraBackup with the –stats parameter https://www.percona.com/doc/percona-xtrabackup/2.2/xtrabackup_bin/analyzing_table_statistics.html

    Downside to using? Overhead?

    The overhead is the one that comes with using Performance Schema. I like the perspective of this presentation (https://www.percona.com/live/mysql-conference-2014/sessions/performanceschema-worth-overhead): Overhead is dynamic. Do  not  rely  on  other  people’s  benchmarks. Benchmark your application and find out what your overhead is.

    What is the performance cost with regards to memory and io when using sys schema? Are there any tweaks or server variables with help the sys schema performing better?

    Use only the instrumentation needed. This blog post have extensive info about the topic http://marcalff.blogspot.com.co/2011/06/performance-schema-overhead-tuning.html

    For replicate how does sys schema record data?

    It doesn’t until MySQL 5.7.2 where the Performance Schema provides tables that expose replication information: https://dev.mysql.com/doc/refman/5.7/en/performance-schema-replication-tables.html and talking about the sys schema, currently the only place where you can find info about replication is in the “diagnostics” procedure, but as you can imagine, it only get’s data if the MySQL version is 5.7.2 or higher.

    Is sys schema built into any o the Percona releases?

    At the moment, no.

    Is it possible to use SYS schema in Galera 3 nodes cluster?

    Yes, since the only requirement is to have performance_schema, which is also available on PXC / Galera Cluster

    Can you create trending off information pulled from the Sys Schema? Full table scans over time, latency over time, that kind of thing?

    Yes, you can use procedures like, for example, “diagnostics

    How do I reset the performance data to start collecting from scratch?

    By calling the ps_truncate_all_tables procedure. Truncate a performance_schema table equals to “clear collected events”. TRUNCATE TABLE can also be used with summary tables, but the effect is to reset the summary columns to 0 or NULL, not to remove rows.

    Can we install SYS schema before 5.6?

    You can use the ps_helper on 5.5 https://github.com/MarkLeith/dbahelper

    Does sys support performance_schema from 5.0?

    Unfortunately, MySQL 5.0 doesn’t have performance_schema. P_S is available since MySQL 5.5.3

    If you install the sys schema on one node of a Galera cluster will all the nodes get the Sys schema? Also, is the Sys schema cluster aware or does it only track the local node?

    For PXC 5.6 with Galera 3, the answer is: yes, it will be replicated to all the nodes. And the performance schema will always only collect data of the local node.

    ##sample 2

    Sys Schema for MySQL 5.6 and MySQL 5.7

    https://www.percona.com/blog/2014/11/20/sys-schema-mysql-5-6-5-7/

    Performance Schema (P_S) has been available since MySQL 5.5, more than 4 years ago. It is still difficult to see production servers with P_S enabled, even with MySQL 5.6 where the feature is enabled by default. There have been several complaints like the overhead, that the fix is a work in progress, and the ease of use. 52 tables to query and 31 configuration variables is enough to scare people.

    There is a solution for the second problem, the usability. It’s name is “sys schema“. It is a collection of views, functions and procedures to make P_S more user friendly.

    Installation

    If you are a MySQL Workbench user the installation is pretty easy because sys schema is already included. You just need to install it. Click on “Performance – Performance Reports” and there you will find the “Install Helper” button that will install sys schema.

    sys schema mysql workbench

    If you don’t use MySQL Workbench you need to download sys_56.sql or sys_57.sql (depends if you use 5.6 or 5.7) from the github repository. Then, just import the sql file as usual:

    Usage

    After the import, you will have a new “sys” schema with some very descriptive table names. Let’s see an example. Do you want to know what tables are using most of our InnoDB buffer memory? Easy:

    Pretty easy and useful, right? You can also get what is the database using more memory in the buffer pool querying innodb_buffer_stats_by_schema.

    For each table there is another similar ones that it’s name starts with x$. For example, you have user_summary_by_file_io and x$user_summary_by_file_io. The difference is that the first table has a human readable output values while the second one has the real values. Let’s see an example:

    For humans, at least for me, it is easier to read seconds rather than picoseconds 

    There are multiple tables with very descriptive names.

    – io_by_thread_by_latency
    – schema_unused_indexes
    – statements_with_temp_tables
    – statements_with_errors_or_warnings
    – user_summary_by_statement_type
    – waits_by_host_by_latency

    There are lot more, and they are explained with examples in project’s README file.

    Configuration

    On the MySQL side nothing special is needed. Just enable performance_schema:

    sys schema also provides some procedures to enable/disable some features. For example:

    – ps_setup_enable_background_threads
    – ps_setup_enable_consumers
    – ps_setup_enable_instrument
    and so on…

    We also have the same procedures with “disable”. After you have made the changes you can save them calling ps_setup_save() and reload it later on if you want calling ps_setup_reload_saved(). If you want to reset the configuration to default values just call ps_setup_reset_to_default().

    For example, we can check that some consumers are disabled. It is possible to enable them and save the configuration:

    Conclusion

    Performance Schema is very useful when we want to know what is happening inside the database. It is getting more features with each new GA and will probably be the single point of information in near future. Now thanks to sys schema it is also easy to use.

  • 相关阅读:
    你好,这里有一份2019年目标检测指南
    谷歌2019 学术指标发榜:CVPR首次进入Top 10,何恺明论文引用最高!
    魔图互联:知识图谱推荐系统-给人们带来更个性化的推荐
    NLPer入门指南 | 完美第一步
    一文总结数据科学家常用的Python库(下)
    一文总结数据科学家常用的Python库(上)
    一文看懂NLP神经网络发展历史中最重要的8个里程碑!
    如何为计算机视觉任务选择正确的标注类型
    C. Queen Codeforces Round #549 (Div. 2) dfs
    D. Equalize Them All Codeforces Round #550 (Div. 3)
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/16203799.html
Copyright © 2020-2023  润新知