


Detailed example of monitoring parameters in performance and sys schema in MySQL5.7
I hope the content I want to share with you will be helpful to you. In MySQL5.7, the performance schema has been greatly improved, including the introduction of a large number of new monitoring items, reduction of space and load, and the use of the new sys schema. The mechanism significantly improves ease of use. This article will introduce to you the explanation of monitoring parameters in performance and sys schema in MySQL5.7. Friends in need can refer to it.
1. Performance schema: Introduction
In MySQL5.7, performance schema has been greatly improved, including the introduction of a large number of newly added monitoring items, reduction of space and load, and through new The sys schema mechanism significantly improves ease of use. In terms of monitoring, the performance schema has the following functions:
①: Metadata lock:
It is crucial to understand the dependencies of metadata locks between sessions. Starting from MySQL 5.7.3, you can learn about metadata locks through the metadata_locks table;
--Which sessions have which metadata locks
--Which sessions are waiting for metadata locks
--Which requests were killed due to deadlocks or lock waiting timeouts?
②: Progress tracking:
Track the progress of long-term operations (such as alter table), from MySQL5. Starting from 7.7, performance schema automatically provides statement progress information. We can view the progress information of the current event through the events_stages_current table;
③: Transaction:
Monitor all aspects of the service layer and storage engine layer transactions. Starting from MySQL 5.7.3, the events_transactions_current table has been added. Transaction monitoring can be turned on through the setup_consumers and setup_instruments tables, and the status of the current transaction can be queried through this table. If the online database encounters a large increase in undo log and a sharp decline in database performance, you can use this table to query whether there are currently uncommitted transactions. If it is found that a large number of transaction states are active, it can be determined that a large number of transactions are uncommitted in the database;
④: Memory usage:
Provides memory usage information statistics, which is helpful for understanding and Adjust the memory consumption of the server. Starting from MySQL5.7.2, performance schema has added memory-related statistical information, which counts the memory usage process from the perspectives of accounts, access hosts, threads, users and events;
⑤: Stored procedures:
Detectors for stored procedures, stored methods, event schedulers and table triggers. In the setup_objects table in MySQL5.7, new detectors for event, function, procedure, and trigger are added. Performance schema is used to detect objects matching object_schema and object_name in the table;
2. Introduction to sys schema:
New sys schema in MySQL5.7. It is a schema composed of a series of objects (views, stored procedures, stored methods, tables and triggers). It does not collect and store any information itself, but summarizes the data in performance_schema and information_schema in a more understandable way. for "view".
---sys schema can be used for typical tuning and diagnostic use cases. These objects include the following three:
①: Summarize performance mode data into a more understandable view;
②: Stored procedures for operations such as performance mode configuration and generating diagnostic reports
③: Stored functions used to query performance mode configuration and provide formatting services
--- The function of sys schema in query can check the usage of database service resources? Which hosts have the most access to the database server? Memory usage on the instance?
3. Classification of tables in sys schema:
①: Host related information:
The view starting with host_summary mainly summarizes the IO delay information from the host , file event type, statement type and other perspectives to display file IO information;
②: innodb related information:
The view starting with innodb summarizes the innodb buffer page information and transaction waiting for innodb lock Information;
③: IO usage:
The view starting with IO summarizes the information of IO users, including waiting for IO and IO usage, displayed in groups from various angles ;
④: Memory usage:
The view starting with memory shows memory usage from the perspective of host, thread, user, and event;
⑤: Connection and session Information:
Among them, the processlist and session-related views summarize the session-related information;
⑥: Table-related information:
The view starting with schema_table, from the entire Table scans, innodb buffer pools, etc. display table statistical information;
⑦: Index information:
It contains the view of the index, which counts the usage of the index, as well as duplicate indexes and unused indexes Index status;
⑧: Statement related information:
The view starting with statement, statistics of standardized statement usage, including the number of errors, warnings, full table scans, Use temporary tables, execution sorting and other information;
⑨: User related information:
The view starting with user counts the file IO used by the user, the statement statistics executed, etc.;
⑨: Waiting for event related information
:
The view starting with wait shows the delay of waiting events from the perspective of host and event;
4. Sys schema usage examples:
---查看表的访问量:(可以监控每张表访问量的情况,或者监控某个库的访问量的变化) select table_schema,table_name,sum(io_read_requests+io_write_requests) from schema_table_statistics; select table_schema,table_name,io_read_requests+io_write_requests as io_total from schema_table_statistics; ---冗余索引和未使用索引的检查:(schema_redundant_indexes和schema_unused_indexes查看索引的情况) select * from sys.schema_redundant_indexes\G select * from sys.schema_unused_indexes; (如果有冗余索引和长期未使用的索引,应该及时清理,) ---查看表自增ID使用情况: select * from schema_auto_increment_columns\G (可以使用schema_auto_increment_columns视图,就能很简单的查到每个表的自增量使用情况,甚至可以精确到某个表的自增量情况) ---监控全表扫描的sql语句: select * from sys.statements_with_full_table_scans where db='test2'\G (使用statements_with_full_table_scans视图可以查看哪些表查询使用了全表扫描,其中exec_count是执行的次数,等信息) ---查看实例消耗的磁盘I/O情况:() select file,avg_read+avg_write as avg_io from io_global_by_file_by_bytes order by avg_io desc limit 10; (查看io_global_by_file_by_bytes视图可以检查磁盘I/O消耗过大的原因,定位问题)
Related recommendations:
Several commonly used mysql monitoring script commands
mysql script to realize automatic monitoring and synchronization
mysql innodb monitoring Detailed explanation of the example code of (system layer, database layer)
The above is the detailed content of Detailed example of monitoring parameters in performance and sys schema in MySQL5.7. For more information, please follow other related articles on the PHP Chinese website!

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool