MySQL- 5.7 sys schema

  performance_schema provide monitoring strategy and monitor a large number of items, including: a metadata lock, progress tracking, transaction, memory usage and storage procedures. However, performance_schema are too complicated, inconvenient operation, it added 5.7 sys schema, the basis of data from the performance with information_shcema two libraries, the database itself is not stored and the data Central Purchasing.

Category 1 view

  1. Host-related
  2. innodb Related
  3. IO-related
  4. Memory-related
  5. Connection associated with the session
  6. Table-related
  7. Related Index
  8. Statement related
  9. User-related
  10. Waiting for information

2 daily application

2.1 Viewing process

     There are three commonly used queries:
show processlist;
show full processlist;
select * from information_schema.processlist;

    Which, show processlist to view a brief statement columns of the current connection to the database, the SQL statement that contains only part of SQL, and show full processlist provides a complete SQL statement, consistent with the content information_schema.processlist show full processlist content, but may form add the query form where conditions for their own needs.

 
    In addition, sys provides the following four views to see the connections, the more detailed the four offers several lines circumstances, a temporary table, the current SQL and SQL final submission (even sleep state, there is also the final submission You can view SQL) and other information.
 
select * from sys.processlist;
select * from sys.session;
select * from sys.x$processlist;
select * from sys.x$session;

    Because SQL provides content for the Summary section, if you want to see the details can be viewed by `performance_schema`.`events_statements_current` table view by thd_id associated sys.processlist of.
 

See Table 2.2 Visits

Copy the code
 select table_schema,table_name,sum(io_read_requests+io_write_requests) io from schema_table_statistics group by table_schema,table_name order by io desc limit 10;
+--------------+----------------------------------+------+
| table_schema | table_name                       | io   |
+--------------+----------------------------------+------+
| ycf_sqlpub   | django_session                   | 2194 |
| dba_sqlpub   | django_session                   |  735 |
| ycf_sqlpub   | sqlversion_registersql           |  347 |
| ycf_sqlpub   | xadmin_log                       |  331 |
| ycf_sqlpub   | sqlversion_registersqllog_sqls   |  329 |
| ycf_sqlpub   | sqlversion_sqlpublishlog_version |  311 |
| ycf_sqlpub   | sqlversion_sqlpublishlog         |  308 |
| ycf_sqlpub   | sqlversion_registersqllog        |  299 |
| ycf_sqlpub   | auth_group_permissions           |  298 |
| ycf_sqlpub   | testenv_testalldb                |  295 |
+--------------+----------------------------------+------+
Copy the code

2.3 unused redundant indexes and index

Copy the code
# Redundancy index view 
the SELECT table_schema, table_name, redundant_index_name, redundant_index_columns, dominant_index_name, dominant_index_columns from sys.schema_redundant_indexes; 

# not use the index to see 
select * from schema_unused_indexes;
Copy the code

Table 2.4 monitor self-energizing ID

select * from schema_auto_increment_columns \G

2.5 Monitoring sql statement full table scan

select * from sys.statements_with_full_table_scans where db = 'test';

2.6 to view the actual files that consume disk IO

select file,avg_read+avg_write as avg_io from io_global_by_file_by_bytes order by avg_io desc limit 10;

3 List view

3.1 Triggers

  • sys_config 
    • System Variables table
    • Notes Link: sys_config
    • Concerns: statement_truncate_len
      • () Length of the truncated SQL influence function format_statement, that is, the total length of the last SQL statement is displayed in the image display length sys.processlist last_statement, it is subject to this function. The length of the display can be dynamically modified session level, default is 64.
  • sys_config_insert_set_user
    • sys_config table INSERT operation occurs, the trigger update sys_config of set_by row triggers
    • show triggers; View source
  • sys_config_update_set_user
    • sys_config table UPDATE operation occurs, the trigger update sys_config of set_by row triggers
    • show triggers; View source

3.2 view

     Sys library will be used daily, is largely query using the view, but the view has been very much at present, divided with x $ prefix with this view without, nothing substantive difference between the two, without x $ view the result is a user-friendly display, there will be some unit conversion, is like linux command -h option, but would like to bring x $ prefix, the raw data units without conversion.
     View so much so, in fact, not much used, will add red font display, other views do a brief introduction.

3.2.1  Host-related

  • Beginning host_summary view
  • IO delay provide other relevant information
  • View substantially as follows (as usual red)
    • The host_summary and x$host_summary Views
    • The host_summary_by_file_io and x$host_summary_by_file_io Views
    • The host_summary_by_file_io_type and x$host_summary_by_file_io_type Views
    • The host_summary_by_stages and x$host_summary_by_stages Views
    • The host_summary_by_statement_latency and x$host_summary_by_statement_latency Views
    • The host_summary_by_statement_type and x$host_summary_by_statement_type Views
  • brief introduction:
    • Daily mainly applies that host_summary view, according to the total number of executed sql host connection to the database, when the chief executive, a table scan, file IO, connectivity, user case and memory distribution, allows DBA to quickly navigate to what station host the most consuming database resources, there is a general understanding of resource usage for all host connections to the database.
    • If you want to see in detail the major consuming IO resources on what file type for each host, you can view host_summary_by_file_io_type view
    • If you look at each case is only the total IO host, you can see the view host_summary_by_file_io

3.2.2 innodb Related

  • The beginning of the innodb view
  • Innodb buffer page summary of information and transaction waiting for lock information innodb
  • View substantially as follows (as usual red, but in fact the best use caution)
    • The innodb_buffer_stats_by_schema and x$innodb_buffer_stats_by_schema Views
    • The innodb_buffer_stats_by_table and x$innodb_buffer_stats_by_table Views
    • The innodb_lock_waits and x$innodb_lock_waits Views
  • brief introduction
    • When there is more than one instance of the business library, due to performance issues, you may want to view the memory usage of each database, you can use the view innodb_buffer_stats_by_schema, but less caution, because it will scan the entire buffer pool to statistics, if the buffer pool instances where very large, then this is a very resource-consuming queries, lacks something not use Ha! This view is actually done by a group by object_schema view innodb_buffer_stats_by_table data obtained.
    • (Screenshot not test environment, so use the little memory)
    • In some cases, need to check occupancy table in memory, you can query through the view innodb_buffer_stats_by_table, but also scans the entire buffer pool statistics, less caution.

3.2.3 IO-related

  • The beginning of the io view
  • IO wait situation / IO usage
  • View substantially as follows (as usual red)
    • The io_by_thread_by_latency and x$io_by_thread_by_latency Views
      • IO usage of each thread
    • The io_global_by_file_by_bytes and x$io_global_by_file_by_bytes Views
      • IO circumstances of each database file
    • The io_global_by_file_by_latency and x$io_global_by_file_by_latency Views
      • IO time-consuming cases each database file
    • The io_global_by_wait_by_bytes and x$io_global_by_wait_by_bytes Views
      • Event database IO wait situation
    • The io_global_by_wait_by_latency and x$io_global_by_wait_by_latency Views
      • IO wait time cost of database events
    • The latest_file_io and x$latest_file_io Views
      • The current situation is to read and write files
  • brief introduction
    • View database instance IO distribution, and focus on optimizing object, you can use io_global_by_file_by_bytes

3.2.4 memory-related

  • The beginning of the memory view
  • Display memory usage from the host / thread / user perspectives
    • The memory_by_host_by_current_bytes and x$memory_by_host_by_current_bytes Views
    • The memory_by_thread_by_current_bytes and x$memory_by_thread_by_current_bytes Views
    • The memory_by_user_by_current_bytes and x$memory_by_user_by_current_bytes Views
    • The memory_global_by_current_bytes and x$memory_global_by_current_bytes Views
    • The memory_global_total and x$memory_global_total Views
  • brief introduction
    • Current memory usage, respectively viewed from the host, thread, user perspectives corresponding to a respective view.

3.2.5 connection associated with the session

  • And the session view comprising processlist
  • Session related information
  • View substantially as follows (as usual red)
    • The processlist and x$processlist Views
    • The session and x$session Views
    • The session_ssl_status View
  • brief introduction
    • Check connection usage, session results with similar processlist. Check connections, there are very many ways, each method has its own usage details, see the description above.

Table 3.2.6 Related

  • Beginning schema_table view
  • From a full table scan / innodb buffer pool performance statistics table
  • View substantially as follows (as usual red)
    • The schema_table_lock_waits and x$schema_table_lock_waits Views
    • The schema_table_statistics and x$schema_table_statistics Views
    • The schema_table_statistics_with_buffer and x$schema_table_statistics_with_buffer Views
    • The schema_tables_with_full_table_scans and x$schema_tables_with_full_table_scans Views
    • The schema_auto_increment_columns View
  • brief introduction
    • View the table of IO situation update, delete, insert, select, you can use schema_table_statistics view
    • View table full table scan, the crawl need to focus on optimizing the object, you can use the View schema_tables_with_full_table_scans
    • See if the table from the fast growth reached a bottleneck, and there is frequent delete some form, may lead to increased self-ID number with the maximum number of form extremely consistent, in order to avoid problems, you can view schema_auto_increment_columns, to see what is about to reach the table auto-incremented value bottleneck

3.2.7 Index-related

  • index view contains
  • View substantially as follows (as usual red, red are added accidentally)
    • The schema_object_overview View
    • The schema_redundant_indexes and x$schema_flattened_keys Views
    • The schema_unused_indexes View
    • The schema_index_statistics and x$schema_index_statistics Views
  • brief introduction
    • View objects and the index distribution within the current instance of each data can be used schema_object_overview
    • View index database redundancy situation, you can view schema_redundant_indexes, but keep in mind that not all redundant indexes to be deleted, please measure the actual usage, index size, and then scan the index of decisions.
    • View database does not use an index, you can use schema_unused_indexes
    • View index select \ update \ delete \ insert, you can use schema_index_statistics

3.2.8 Statement related

  • The beginning of the statement view
  • The number of errors, warnings, number, perform a full table scan, using a temporary table, perform sorting and other information
  • View roughly as follows (red for common functions very powerful, is actually quite a few used)
    • The statement_analysis and x$statement_analysis Views
    • The statements_with_errors_or_warnings and x$statements_with_errors_or_warnings Views
    • The statements_with_full_table_scans and x$statements_with_full_table_scans Views
    • The statements_with_runtimes_in_95th_percentile and x$statements_with_runtimes_in_95th_percentile Views
    • The statements_with_sorting and x$statements_with_sorting Views
    • The statements_with_temp_tables and x$statements_with_temp_tables Views
  • A brief description
    • Summary SQL in the number of errors, warnings, number, perform a full table scan, using a temporary table, perform sorting and other information, sql statement also use format_statement () function does the length limit, if you want to see the complete SQL, can this column via this form View performance_schema`.`events_statements_summary_by_digest`.`DIGEST_TEXT`, add columns is associated DIGEST

3.2.9 User-related

  • The beginning of the user view
  • Users of file IO / execution statistics statement
  • View substantially as follows (as usual red)
    • The user_summary and x$user_summary Views
    • The user_summary_by_file_io and x$user_summary_by_file_io Views
    • The user_summary_by_file_io_type and x$user_summary_by_file_io_type Views
    • The user_summary_by_stages and x$user_summary_by_stages Views
    • The user_summary_by_statement_latency and x$user_summary_by_statement_latency Views
    • The user_summary_by_statement_type and x$user_summary_by_statement_type Views
  • brief introduction
    • IO situation from the perspective of the user, respectively, the statistics file, sql implementation, if a user database is divided according to the service module, then you can clearly see which are more resource-intensive business

3.2.10 wait for information

  • The beginning of the wait View
    • The wait_classes_global_by_avg_latency and x$wait_classes_global_by_avg_latency Views
      • Grouped by event event, long-time statistical average delay of each event
    • The wait_classes_global_by_latency and x$wait_classes_global_by_latency Views
      • Grouped by event event, long-time statistical total delay of each event
    • The waits_by_host_by_latency and x$waits_by_host_by_latency Views
    • The waits_by_user_by_latency and x$waits_by_user_by_latency Views
    • The waits_global_by_latency and x$waits_global_by_latency Views
      • All event of delays
  • brief introduction
    • Wait class view, respectively from the event, the host, such as a user point of view, query analysis

Description link

Guess you like

Origin www.cnblogs.com/VicLiu/p/12640973.html