【MySQL精通之路】InnoDB-INFORMATION_SCHEMA库Metrics表

1.介绍

INNODB_METRICS表提供了有关INNODB性能资源相关计数器的信息

INNODB_METRICS表列如下所示。

有关列描述,请参阅“INFORMATION_SCHEMAINNODB_METRICS表”。

【MySQL精通之路】INFORMATION_SCHEMA库-INNODB_METRICS表-CSDN博客

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************NAME: dml_insertsSUBSYSTEM: dmlCOUNT: 46273MAX_COUNT: 46273MIN_COUNT: NULLAVG_COUNT: 492.2659574468085COUNT_RESET: 46273
MAX_COUNT_RESET: 46273
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULLTIME_ENABLED: 2014-11-28 16:07:53TIME_DISABLED: NULLTIME_ELAPSED: 94TIME_RESET: NULLSTATUS: enabledTYPE: status_counterCOMMENT: Number of rows inserted

启用、禁用和重置计数器
您可以使用以下变量启用、禁用和重置计数器:

innodb_monitor_enable: 启用计数

SET GLOBAL innodb_monitor_enable = [counter-name|module_name|pattern|all];

innodb_monitor_disable: 禁用计数

SET GLOBAL innodb_monitor_reset = [counter-name|module_name|pattern|all];

innodb_monitor_reset: 将计数重置为零

SET GLOBAL innodb_monitor_reset = [counter-name|module_name|pattern|all];

innodb_monitor_reset_all:重置所有计数器值。在使用innodb_monitor_reset_all之前,必须禁用计数器。

SET GLOBAL innodb_monitor_reset_all = [counter-name|module_name|pattern|all];

计数器和计数器模块也可以在启动时使用MySQL服务器配置文件启用

例如:

要启用日志模块metadata_table_handles_openedmetadata_ttable_handles_connected计数器,请在MySQL服务器配置文件的[mysqld]部分中输入以下行。

[mysqld]
innodb_monitor_enable = log,metadata_table_handles_opened,metadata_table_handles_closed

在配置文件中启用多个计数器或模块时,请指定innodb_monitor_enable变量,后跟用逗号分隔的计数器和模块名称,如上所示。配置文件中只能使用innodb_monitor_enable变量。innodb_monitor_disableinnodb_monitor _reset变量仅在命令行上受支持。

注意:

因为每个计数器都会增加一定程度的运行时开销,所以在生产服务器上保守地使用计数器来诊断特定问题或监视特定功能。建议使用测试或开发服务器以更广泛地使用计数器。

2.计数器

可用计数器的列表可能会更改。在Information Schema库 INNODB_METRICS表中查询MySQL服务器版本中可用的计数器。

默认启用的计数器对应于SHOW ENGINE INNODB STATUS输出中显示的计数器。

SHOW ENGINE INNODB STATUS输出中显示的计数器始终在系统级别启用,但可以禁用INNODB_METRICS表。

计数器状态不是持久的。

除非另有配置,否则当服务器重新启动时,计数器将恢复到默认的启用或禁用状态

如果您运行的程序会受到计数器添加删除的影响,建议您查看发行说明并查询INNODB_METRICS表,以将这些更改标识为升级过程的一部分。

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS ORDER BY NAME;
+---------------------------------------------+---------------------+----------+
| name                                        | subsystem           | status   |
+---------------------------------------------+---------------------+----------+
| adaptive_hash_pages_added                   | adaptive_hash_index | disabled |
| adaptive_hash_pages_removed                 | adaptive_hash_index | disabled |
| adaptive_hash_rows_added                    | adaptive_hash_index | disabled |
| adaptive_hash_rows_deleted_no_hash_entry    | adaptive_hash_index | disabled |
| adaptive_hash_rows_removed                  | adaptive_hash_index | disabled |
| adaptive_hash_rows_updated                  | adaptive_hash_index | disabled |
| adaptive_hash_searches                      | adaptive_hash_index | enabled  |
| adaptive_hash_searches_btree                | adaptive_hash_index | enabled  |
| buffer_data_reads                           | buffer              | enabled  |
| buffer_data_written                         | buffer              | enabled  |
| buffer_flush_adaptive                       | buffer              | disabled |
| buffer_flush_adaptive_avg_pass              | buffer              | disabled |
| buffer_flush_adaptive_avg_time_est          | buffer              | disabled |
| buffer_flush_adaptive_avg_time_slot         | buffer              | disabled |
| buffer_flush_adaptive_avg_time_thread       | buffer              | disabled |
| buffer_flush_adaptive_pages                 | buffer              | disabled |
| buffer_flush_adaptive_total_pages           | buffer              | disabled |
| buffer_flush_avg_page_rate                  | buffer              | disabled |
| buffer_flush_avg_pass                       | buffer              | disabled |
| buffer_flush_avg_time                       | buffer              | disabled |
| buffer_flush_background                     | buffer              | disabled |
| buffer_flush_background_pages               | buffer              | disabled |
| buffer_flush_background_total_pages         | buffer              | disabled |
| buffer_flush_batches                        | buffer              | disabled |
| buffer_flush_batch_num_scan                 | buffer              | disabled |
| buffer_flush_batch_pages                    | buffer              | disabled |
| buffer_flush_batch_scanned                  | buffer              | disabled |
| buffer_flush_batch_scanned_per_call         | buffer              | disabled |
| buffer_flush_batch_total_pages              | buffer              | disabled |
| buffer_flush_lsn_avg_rate                   | buffer              | disabled |
| buffer_flush_neighbor                       | buffer              | disabled |
| buffer_flush_neighbor_pages                 | buffer              | disabled |
| buffer_flush_neighbor_total_pages           | buffer              | disabled |
| buffer_flush_n_to_flush_by_age              | buffer              | disabled |
| buffer_flush_n_to_flush_by_dirty_page       | buffer              | disabled |
| buffer_flush_n_to_flush_requested           | buffer              | disabled |
| buffer_flush_pct_for_dirty                  | buffer              | disabled |
| buffer_flush_pct_for_lsn                    | buffer              | disabled |
| buffer_flush_sync                           | buffer              | disabled |
| buffer_flush_sync_pages                     | buffer              | disabled |
| buffer_flush_sync_total_pages               | buffer              | disabled |
| buffer_flush_sync_waits                     | buffer              | disabled |
| buffer_LRU_batches_evict                    | buffer              | disabled |
| buffer_LRU_batches_flush                    | buffer              | disabled |
| buffer_LRU_batch_evict_pages                | buffer              | disabled |
| buffer_LRU_batch_evict_total_pages          | buffer              | disabled |
| buffer_LRU_batch_flush_avg_pass             | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_est         | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_slot        | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_thread      | buffer              | disabled |
| buffer_LRU_batch_flush_pages                | buffer              | disabled |
| buffer_LRU_batch_flush_total_pages          | buffer              | disabled |
| buffer_LRU_batch_num_scan                   | buffer              | disabled |
| buffer_LRU_batch_scanned                    | buffer              | disabled |
| buffer_LRU_batch_scanned_per_call           | buffer              | disabled |
| buffer_LRU_get_free_loops                   | buffer              | disabled |
| buffer_LRU_get_free_search                  | Buffer              | disabled |
| buffer_LRU_get_free_waits                   | buffer              | disabled |
| buffer_LRU_search_num_scan                  | buffer              | disabled |
| buffer_LRU_search_scanned                   | buffer              | disabled |
| buffer_LRU_search_scanned_per_call          | buffer              | disabled |
| buffer_LRU_single_flush_failure_count       | Buffer              | disabled |
| buffer_LRU_single_flush_num_scan            | buffer              | disabled |
| buffer_LRU_single_flush_scanned             | buffer              | disabled |
| buffer_LRU_single_flush_scanned_per_call    | buffer              | disabled |
| buffer_LRU_unzip_search_num_scan            | buffer              | disabled |
| buffer_LRU_unzip_search_scanned             | buffer              | disabled |
| buffer_LRU_unzip_search_scanned_per_call    | buffer              | disabled |
| buffer_pages_created                        | buffer              | enabled  |
| buffer_pages_read                           | buffer              | enabled  |
| buffer_pages_written                        | buffer              | enabled  |
| buffer_page_read_blob                       | buffer_page_io      | disabled |
| buffer_page_read_fsp_hdr                    | buffer_page_io      | disabled |
| buffer_page_read_ibuf_bitmap                | buffer_page_io      | disabled |
| buffer_page_read_ibuf_free_list             | buffer_page_io      | disabled |
| buffer_page_read_index_ibuf_leaf            | buffer_page_io      | disabled |
| buffer_page_read_index_ibuf_non_leaf        | buffer_page_io      | disabled |
| buffer_page_read_index_inode                | buffer_page_io      | disabled |
| buffer_page_read_index_leaf                 | buffer_page_io      | disabled |
| buffer_page_read_index_non_leaf             | buffer_page_io      | disabled |
| buffer_page_read_other                      | buffer_page_io      | disabled |
| buffer_page_read_rseg_array                 | buffer_page_io      | disabled |
| buffer_page_read_system_page                | buffer_page_io      | disabled |
| buffer_page_read_trx_system                 | buffer_page_io      | disabled |
| buffer_page_read_undo_log                   | buffer_page_io      | disabled |
| buffer_page_read_xdes                       | buffer_page_io      | disabled |
| buffer_page_read_zblob                      | buffer_page_io      | disabled |
| buffer_page_read_zblob2                     | buffer_page_io      | disabled |
| buffer_page_written_blob                    | buffer_page_io      | disabled |
| buffer_page_written_fsp_hdr                 | buffer_page_io      | disabled |
| buffer_page_written_ibuf_bitmap             | buffer_page_io      | disabled |
| buffer_page_written_ibuf_free_list          | buffer_page_io      | disabled |
| buffer_page_written_index_ibuf_leaf         | buffer_page_io      | disabled |
| buffer_page_written_index_ibuf_non_leaf     | buffer_page_io      | disabled |
| buffer_page_written_index_inode             | buffer_page_io      | disabled |
| buffer_page_written_index_leaf              | buffer_page_io      | disabled |
| buffer_page_written_index_non_leaf          | buffer_page_io      | disabled |
| buffer_page_written_on_log_no_waits         | buffer_page_io      | disabled |
| buffer_page_written_on_log_waits            | buffer_page_io      | disabled |
| buffer_page_written_on_log_wait_loops       | buffer_page_io      | disabled |
| buffer_page_written_other                   | buffer_page_io      | disabled |
| buffer_page_written_rseg_array              | buffer_page_io      | disabled |
| buffer_page_written_system_page             | buffer_page_io      | disabled |
| buffer_page_written_trx_system              | buffer_page_io      | disabled |
| buffer_page_written_undo_log                | buffer_page_io      | disabled |
| buffer_page_written_xdes                    | buffer_page_io      | disabled |
| buffer_page_written_zblob                   | buffer_page_io      | disabled |
| buffer_page_written_zblob2                  | buffer_page_io      | disabled |
| buffer_pool_bytes_data                      | buffer              | enabled  |
| buffer_pool_bytes_dirty                     | buffer              | enabled  |
| buffer_pool_pages_data                      | buffer              | enabled  |
| buffer_pool_pages_dirty                     | buffer              | enabled  |
| buffer_pool_pages_free                      | buffer              | enabled  |
| buffer_pool_pages_misc                      | buffer              | enabled  |
| buffer_pool_pages_total                     | buffer              | enabled  |
| buffer_pool_reads                           | buffer              | enabled  |
| buffer_pool_read_ahead                      | buffer              | enabled  |
| buffer_pool_read_ahead_evicted              | buffer              | enabled  |
| buffer_pool_read_requests                   | buffer              | enabled  |
| buffer_pool_size                            | server              | enabled  |
| buffer_pool_wait_free                       | buffer              | enabled  |
| buffer_pool_write_requests                  | buffer              | enabled  |
| compression_pad_decrements                  | compression         | disabled |
| compression_pad_increments                  | compression         | disabled |
| compress_pages_compressed                   | compression         | disabled |
| compress_pages_decompressed                 | compression         | disabled |
| cpu_n                                       | cpu                 | disabled |
| cpu_stime_abs                               | cpu                 | disabled |
| cpu_stime_pct                               | cpu                 | disabled |
| cpu_utime_abs                               | cpu                 | disabled |
| cpu_utime_pct                               | cpu                 | disabled |
| dblwr_async_requests                        | dblwr               | disabled |
| dblwr_flush_requests                        | dblwr               | disabled |
| dblwr_flush_wait_events                     | dblwr               | disabled |
| dblwr_sync_requests                         | dblwr               | disabled |
| ddl_background_drop_tables                  | ddl                 | disabled |
| ddl_log_file_alter_table                    | ddl                 | disabled |
| ddl_online_create_index                     | ddl                 | disabled |
| ddl_pending_alter_table                     | ddl                 | disabled |
| ddl_sort_file_alter_table                   | ddl                 | disabled |
| dml_deletes                                 | dml                 | enabled  |
| dml_inserts                                 | dml                 | enabled  |
| dml_reads                                   | dml                 | disabled |
| dml_system_deletes                          | dml                 | enabled  |
| dml_system_inserts                          | dml                 | enabled  |
| dml_system_reads                            | dml                 | enabled  |
| dml_system_updates                          | dml                 | enabled  |
| dml_updates                                 | dml                 | enabled  |
| file_num_open_files                         | file_system         | enabled  |
| ibuf_merges                                 | change_buffer       | enabled  |
| ibuf_merges_delete                          | change_buffer       | enabled  |
| ibuf_merges_delete_mark                     | change_buffer       | enabled  |
| ibuf_merges_discard_delete                  | change_buffer       | enabled  |
| ibuf_merges_discard_delete_mark             | change_buffer       | enabled  |
| ibuf_merges_discard_insert                  | change_buffer       | enabled  |
| ibuf_merges_insert                          | change_buffer       | enabled  |
| ibuf_size                                   | change_buffer       | enabled  |
| icp_attempts                                | icp                 | disabled |
| icp_match                                   | icp                 | disabled |
| icp_no_match                                | icp                 | disabled |
| icp_out_of_range                            | icp                 | disabled |
| index_page_discards                         | index               | disabled |
| index_page_merge_attempts                   | index               | disabled |
| index_page_merge_successful                 | index               | disabled |
| index_page_reorg_attempts                   | index               | disabled |
| index_page_reorg_successful                 | index               | disabled |
| index_page_splits                           | index               | disabled |
| innodb_activity_count                       | server              | enabled  |
| innodb_background_drop_table_usec           | server              | disabled |
| innodb_dblwr_pages_written                  | server              | enabled  |
| innodb_dblwr_writes                         | server              | enabled  |
| innodb_dict_lru_count                       | server              | disabled |
| innodb_dict_lru_usec                        | server              | disabled |
| innodb_ibuf_merge_usec                      | server              | disabled |
| innodb_master_active_loops                  | server              | disabled |
| innodb_master_idle_loops                    | server              | disabled |
| innodb_master_purge_usec                    | server              | disabled |
| innodb_master_thread_sleeps                 | server              | disabled |
| innodb_mem_validate_usec                    | server              | disabled |
| innodb_page_size                            | server              | enabled  |
| innodb_rwlock_sx_os_waits                   | server              | enabled  |
| innodb_rwlock_sx_spin_rounds                | server              | enabled  |
| innodb_rwlock_sx_spin_waits                 | server              | enabled  |
| innodb_rwlock_s_os_waits                    | server              | enabled  |
| innodb_rwlock_s_spin_rounds                 | server              | enabled  |
| innodb_rwlock_s_spin_waits                  | server              | enabled  |
| innodb_rwlock_x_os_waits                    | server              | enabled  |
| innodb_rwlock_x_spin_rounds                 | server              | enabled  |
| innodb_rwlock_x_spin_waits                  | server              | enabled  |
| lock_deadlocks                              | lock                | enabled  |
| lock_deadlock_false_positives               | lock                | enabled  |
| lock_deadlock_rounds                        | lock                | enabled  |
| lock_rec_grant_attempts                     | lock                | enabled  |
| lock_rec_locks                              | lock                | disabled |
| lock_rec_lock_created                       | lock                | disabled |
| lock_rec_lock_removed                       | lock                | disabled |
| lock_rec_lock_requests                      | lock                | disabled |
| lock_rec_lock_waits                         | lock                | disabled |
| lock_rec_release_attempts                   | lock                | enabled  |
| lock_row_lock_current_waits                 | lock                | enabled  |
| lock_row_lock_time                          | lock                | enabled  |
| lock_row_lock_time_avg                      | lock                | enabled  |
| lock_row_lock_time_max                      | lock                | enabled  |
| lock_row_lock_waits                         | lock                | enabled  |
| lock_schedule_refreshes                     | lock                | enabled  |
| lock_table_locks                            | lock                | disabled |
| lock_table_lock_created                     | lock                | disabled |
| lock_table_lock_removed                     | lock                | disabled |
| lock_table_lock_waits                       | lock                | disabled |
| lock_threads_waiting                        | lock                | enabled  |
| lock_timeouts                               | lock                | enabled  |
| log_checkpoints                             | log                 | disabled |
| log_concurrency_margin                      | log                 | disabled |
| log_flusher_no_waits                        | log                 | disabled |
| log_flusher_waits                           | log                 | disabled |
| log_flusher_wait_loops                      | log                 | disabled |
| log_flush_avg_time                          | log                 | disabled |
| log_flush_lsn_avg_rate                      | log                 | disabled |
| log_flush_max_time                          | log                 | disabled |
| log_flush_notifier_no_waits                 | log                 | disabled |
| log_flush_notifier_waits                    | log                 | disabled |
| log_flush_notifier_wait_loops               | log                 | disabled |
| log_flush_total_time                        | log                 | disabled |
| log_free_space                              | log                 | disabled |
| log_full_block_writes                       | log                 | disabled |
| log_lsn_archived                            | log                 | disabled |
| log_lsn_buf_dirty_pages_added               | log                 | disabled |
| log_lsn_buf_pool_oldest_approx              | log                 | disabled |
| log_lsn_buf_pool_oldest_lwm                 | log                 | disabled |
| log_lsn_checkpoint_age                      | log                 | disabled |
| log_lsn_current                             | log                 | disabled |
| log_lsn_last_checkpoint                     | log                 | disabled |
| log_lsn_last_flush                          | log                 | disabled |
| log_max_modified_age_async                  | log                 | disabled |
| log_max_modified_age_sync                   | log                 | disabled |
| log_next_file                               | log                 | disabled |
| log_on_buffer_space_no_waits                | log                 | disabled |
| log_on_buffer_space_waits                   | log                 | disabled |
| log_on_buffer_space_wait_loops              | log                 | disabled |
| log_on_file_space_no_waits                  | log                 | disabled |
| log_on_file_space_waits                     | log                 | disabled |
| log_on_file_space_wait_loops                | log                 | disabled |
| log_on_flush_no_waits                       | log                 | disabled |
| log_on_flush_waits                          | log                 | disabled |
| log_on_flush_wait_loops                     | log                 | disabled |
| log_on_recent_closed_wait_loops             | log                 | disabled |
| log_on_recent_written_wait_loops            | log                 | disabled |
| log_on_write_no_waits                       | log                 | disabled |
| log_on_write_waits                          | log                 | disabled |
| log_on_write_wait_loops                     | log                 | disabled |
| log_padded                                  | log                 | disabled |
| log_partial_block_writes                    | log                 | disabled |
| log_waits                                   | log                 | enabled  |
| log_writer_no_waits                         | log                 | disabled |
| log_writer_on_archiver_waits                | log                 | disabled |
| log_writer_on_file_space_waits              | log                 | disabled |
| log_writer_waits                            | log                 | disabled |
| log_writer_wait_loops                       | log                 | disabled |
| log_writes                                  | log                 | enabled  |
| log_write_notifier_no_waits                 | log                 | disabled |
| log_write_notifier_waits                    | log                 | disabled |
| log_write_notifier_wait_loops               | log                 | disabled |
| log_write_requests                          | log                 | enabled  |
| log_write_to_file_requests_interval         | log                 | disabled |
| metadata_table_handles_closed               | metadata            | disabled |
| metadata_table_handles_opened               | metadata            | disabled |
| metadata_table_reference_count              | metadata            | disabled |
| module_cpu                                  | cpu                 | disabled |
| module_dblwr                                | dblwr               | disabled |
| module_page_track                           | page_track          | disabled |
| os_data_fsyncs                              | os                  | enabled  |
| os_data_reads                               | os                  | enabled  |
| os_data_writes                              | os                  | enabled  |
| os_log_bytes_written                        | os                  | enabled  |
| os_log_fsyncs                               | os                  | enabled  |
| os_log_pending_fsyncs                       | os                  | enabled  |
| os_log_pending_writes                       | os                  | enabled  |
| os_pending_reads                            | os                  | disabled |
| os_pending_writes                           | os                  | disabled |
| page_track_checkpoint_partial_flush_request | page_track          | disabled |
| page_track_full_block_writes                | page_track          | disabled |
| page_track_partial_block_writes             | page_track          | disabled |
| page_track_resets                           | page_track          | disabled |
| purge_del_mark_records                      | purge               | disabled |
| purge_dml_delay_usec                        | purge               | disabled |
| purge_invoked                               | purge               | disabled |
| purge_resume_count                          | purge               | disabled |
| purge_stop_count                            | purge               | disabled |
| purge_truncate_history_count                | purge               | disabled |
| purge_truncate_history_usec                 | purge               | disabled |
| purge_undo_log_pages                        | purge               | disabled |
| purge_upd_exist_or_extern_records           | purge               | disabled |
| sampled_pages_read                          | sampling            | disabled |
| sampled_pages_skipped                       | sampling            | disabled |
| trx_active_transactions                     | transaction         | disabled |
| trx_allocations                             | transaction         | disabled |
| trx_commits_insert_update                   | transaction         | disabled |
| trx_nl_ro_commits                           | transaction         | disabled |
| trx_on_log_no_waits                         | transaction         | disabled |
| trx_on_log_waits                            | transaction         | disabled |
| trx_on_log_wait_loops                       | transaction         | disabled |
| trx_rollbacks                               | transaction         | disabled |
| trx_rollbacks_savepoint                     | transaction         | disabled |
| trx_rollback_active                         | transaction         | disabled |
| trx_ro_commits                              | transaction         | disabled |
| trx_rseg_current_size                       | transaction         | disabled |
| trx_rseg_history_len                        | transaction         | enabled  |
| trx_rw_commits                              | transaction         | disabled |
| trx_undo_slots_cached                       | transaction         | disabled |
| trx_undo_slots_used                         | transaction         | disabled |
| undo_truncate_count                         | undo                | disabled |
| undo_truncate_done_logging_count            | undo                | disabled |
| undo_truncate_start_logging_count           | undo                | disabled |
| undo_truncate_usec                          | undo                | disabled |
+---------------------------------------------+---------------------+----------+
314 rows in set (0.00 sec)

3.计数器模块

每个计数器都与一个特定的模块相关联。模块名称可用于启用、禁用或重置特定子系统的所有计数器。例如,使用module_dml启用与dml子系统关联的所有计数器。

mysql> SET GLOBAL innodb_monitor_enable = module_dml;mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICSWHERE subsystem ='dml';
+-------------+-----------+---------+
| name        | subsystem | status  |
+-------------+-----------+---------+
| dml_reads   | dml       | enabled |
| dml_inserts | dml       | enabled |
| dml_deletes | dml       | enabled |
| dml_updates | dml       | enabled |
+-------------+-----------+---------+

模块名称可以与innodb_monitor_enable和相关变量一起使用。

下面列出了模块名称和相应的SUBSYSTEM名称。

module_adaptive_hash (subsystem = adaptive_hash_index)

module_buffer (subsystem = buffer)

module_buffer_page (subsystem = buffer_page_io)

module_compress (subsystem = compression)

module_ddl (subsystem = ddl)

module_dml (subsystem = dml)

module_file (subsystem = file_system)

module_ibuf_system (subsystem = change_buffer)

module_icp (subsystem = icp)

module_index (subsystem = index)

module_innodb (subsystem = innodb)

module_lock (subsystem = lock)

module_log (subsystem = log)

module_metadata (subsystem = metadata)

module_os (subsystem = os)

module_purge (subsystem = purge)

module_trx (subsystem = transaction)

module_undo (subsystem = undo)

4.计数器的使用

示例使用INNODB_METRICS表计数器

此示例演示启用、禁用和重置计数器,以及查询INNODB_METRICS表中的计数器数据。

建表:

mysql> USE test;
Database changedmysql> CREATE TABLE t1 (c1 INT) ENGINE=INNODB;
Query OK, 0 rows affected (0.02 sec)

开启 dml_inserts 计数器.

mysql> SET GLOBAL innodb_monitor_enable = dml_inserts;
Query OK, 0 rows affected (0.01 sec)

可以在INNODB_METRICS表的COMMENT列中找到dml_inserts计数器的描述:

mysql> SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts";
+-------------+-------------------------+
| NAME        | COMMENT                 |
+-------------+-------------------------+
| dml_inserts | Number of rows inserted |
+-------------+-------------------------+

查询INNODB_METRICS表中的dml_inserts计数器数据。因为没有执行DML操作,所以计数器值为零或NULL。TIME_ENABLED和TIME_ELAPSED值指示计数器上次启用的时间以及自该时间以来经过的秒数。

mysql>  SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************NAME: dml_insertsSUBSYSTEM: dmlCOUNT: 0MAX_COUNT: 0MIN_COUNT: NULLAVG_COUNT: 0COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULLTIME_ENABLED: 2014-12-04 14:18:28TIME_DISABLED: NULLTIME_ELAPSED: 28TIME_RESET: NULLSTATUS: enabledTYPE: status_counterCOMMENT: Number of rows inserted

在表中插入三行数据。

mysql> INSERT INTO t1 values(1);
Query OK, 1 row affected (0.00 sec)mysql> INSERT INTO t1 values(2);
Query OK, 1 row affected (0.00 sec)mysql> INSERT INTO t1 values(3);
Query OK, 1 row affected (0.00 sec)

再次查询INNODB_METRICS表中的dml_inserts计数器数据。现在,许多计数器值已递增,包括COUNT、MAX_COUNT、AVG_COUNT和COUNT_RESET。有关这些值的描述,请参阅INNODB_METRICS表定义。

mysql>  SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************NAME: dml_insertsSUBSYSTEM: dmlCOUNT: 3MAX_COUNT: 3MIN_COUNT: NULLAVG_COUNT: 0.046153846153846156COUNT_RESET: 3
MAX_COUNT_RESET: 3
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULLTIME_ENABLED: 2014-12-04 14:18:28TIME_DISABLED: NULLTIME_ELAPSED: 65TIME_RESET: NULLSTATUS: enabledTYPE: status_counterCOMMENT: Number of rows inserted

重置dml_inserts计数器,并再次查询INNODB_METRICS表中的dml_inserters计数器数据。先前报告的%_RESET值(如COUNT_RESET和MAX_RESET)将设置回零。COUNT、MAX_COUNT和AVG_COUNT等值从计数器启用时开始累积收集数据,不受重置的影响。

mysql> SET GLOBAL innodb_monitor_reset = dml_inserts;
Query OK, 0 rows affected (0.00 sec)mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************NAME: dml_insertsSUBSYSTEM: dmlCOUNT: 3MAX_COUNT: 3MIN_COUNT: NULLAVG_COUNT: 0.03529411764705882COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0TIME_ENABLED: 2014-12-04 14:18:28TIME_DISABLED: NULLTIME_ELAPSED: 85TIME_RESET: 2014-12-04 14:19:44STATUS: enabledTYPE: status_counterCOMMENT: Number of rows inserted

要重置所有计数器值,必须首先禁用计数器。禁用计数器会将STATUS值设置为disabled。

mysql> SET GLOBAL innodb_monitor_disable = dml_inserts;
Query OK, 0 rows affected (0.00 sec)mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************NAME: dml_insertsSUBSYSTEM: dmlCOUNT: 3MAX_COUNT: 3MIN_COUNT: NULLAVG_COUNT: 0.030612244897959183COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0TIME_ENABLED: 2014-12-04 14:18:28TIME_DISABLED: 2014-12-04 14:20:06TIME_ELAPSED: 98TIME_RESET: NULLSTATUS: disabledTYPE: status_counterCOMMENT: Number of rows inserted

注意:
计数器和模块名称支持通配符匹配。例如,您可以指定dml_i%,而不是指定完整的dml_inserts计数器名称。您还可以使用通配符匹配同时启用、禁用或重置多个计数器或模块。例如,指定dml_%以启用、禁用或重置所有以dml_开头的计数器。

禁用计数器后,可以使用innodb_monitor_reset_all选项重置所有计数器值。所有值都设置为零或NULL。

mysql> SET GLOBAL innodb_monitor_reset_all = dml_inserts;
Query OK, 0 rows affected (0.00 sec)mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************NAME: dml_insertsSUBSYSTEM: dmlCOUNT: 0MAX_COUNT: NULLMIN_COUNT: NULLAVG_COUNT: NULLCOUNT_RESET: 0
MAX_COUNT_RESET: NULL
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULLTIME_ENABLED: NULLTIME_DISABLED: NULLTIME_ELAPSED: NULLTIME_RESET: NULLSTATUS: disabledTYPE: status_counterCOMMENT: Number of rows inserted

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/840274.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

好书推荐|MATLAB科技绘图与数据分析

提升你的数据洞察力,用于精确绘图和分析的高级MATLAB技术 MATLAB科技绘图与数据分析——jd 本书内容 《MATLAB科技绘图与数据分析》结合作者多年的数据分析与科研绘图经验,详细讲解MATLAB在科技图表制作与数据分析中的使用方法与技巧。全书分为3部分&a…

C语言 数组——数组的定义和初始化

目录 为什么使用数组(Array)? 一维数组的定义 一维数组的初始化 一维数组元素的访问 一维数组元素的赋值 数组的逻辑存储结构 数组的物理存储结构 二维数组的定义和初始化 为什么使用数组(Array)? 一维数组的定义 一维 数组的定义 int a[10]; 定义一个有 10 个 int 型元素的…

云WAF在应对新型网络攻击中的作用是什么?

云WAF(Web Application Firewall)在应对新型网络攻击中扮演着至关重要的角色。以下是云WAF的主要作用: 实时防御与智能分析 云WAF能够实时监测并分析网络流量,一旦发现潜在攻击行为立即进行阻断,有效防止各类Web应用层…

构建传统企业信息化数字化智能化技术架构:挑战与机遇

随着数字化和智能化技术的快速发展,传统企业在信息化转型过程中面临着前所未有的机遇和挑战。如何构建适应企业需求的信息化数字化智能化技术架构,成为企业发展的关键之一。本文将探讨传统企业信息化数字化智能化技术架构的设计与实践。 一、数字化转型的…

【缺失的第一个正数】leetcode,python

真是越做越觉得自己所学尚浅,, 啊??????? 直接上石山代码:(过不了一点)。。。。。 class Solution:def firstMissingPositive(self…

SpringBoot发送邮箱

一、导入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId> </dependency> 二、添加配置 application.yml文件 将username修改为自己的邮箱&#xff0c;password修改为…

SQL——DDL之数据表的操作

基础 # 每一列都要指定对应的类型 # 字符串&#xff1a;varchar(N) # 整数&#xff1a;int # 小数&#xff1a;double # 年月日&#xff1a;date # 年月日时分秒&#xff1a;datetime# 创建表 create table if not exists db_bigdata.student(stuid varchar(10),stuname varch…

[集群聊天服务器]----(四)MySQL数据库模块

上一节我们对网络模块和业务模块进行了解耦[集群聊天服务器]----(三)ChatService模块&#xff0c;解耦网络模块和业务模块&#xff0c;封装了回调函数。在项目中需要使用mysql数据库进行存储用户重要数据&#xff0c;并进行增删改查操作。&#xff0c;所以这一节我们对mysql的封…

Linux基础入门和帮助-第二篇

马哥教育 Linux SRE 学习笔记 用户登录信息查看命令 whoami: 显示当前登录有效用户 [rootrocky8 ~]$whoami rootwho: 系统当前所有的登录会话 [rootrocky8 ~]$who root pts/0 2024-05-24 12:55 (10.0.0.1)w: 系统当前所有的登录会话及所做的操作 [rootrocky8 ~]…

python对矩阵列进行操作

在Python中&#xff0c;可以使用NumPy库来对矩阵&#xff08;或称为矩阵、数组&#xff09;的列进行各种操作。以下是一些常见的列操作及其示例代码&#xff1a; import pandas as pd# 读取CSV文件 df pd.read_csv(output_file.csv, delimiter )# 对列进行求和 sum_columns …

WordPress 发布了独立的 SQLite 插件

之前 WordPress 在官方的 Performance Lab 插件实现 SQLite 模块&#xff0c;现在重构 SQLite 的实现&#xff0c;并且将其发布成一个独立的插件&#xff1a;SQLite Database Integration。 独立 SQLite 插件 最初的功能模块实现是基于 aaemnnosttv 的 wp-sqlite-db 插件修改实…

用ssh做跳板用周转服务器帮我们加速下载

假设有一台机器A&#xff0c;它从网站B下载东西很慢&#xff0c;但是有一台机器C&#xff0c;它从B下载比较快&#xff0c;它和A之间的速度也比较快&#xff0c;那么就可以在A发指令&#xff0c;通过ssh做跳板从C加速下载网站B的文件。 以下为示例命令&#xff1a; ssh 用户名…

【DevOps】Linux 下安装配置 Apache 服务器:打造你的专属 Web 平台

目录 一、准备工作 二、安装 Apache 三、启动和管理 Apache 四、验证安装 五、配置 Apache 5.1 修改网站根目录 5.2 配置虚拟主机 5.2.1 创建虚拟主机配置文件 5.2.2 创建网站目录 5.2.3 启用虚拟主机 5.2.4 重启 Apache 5.3 配置 HTTPS 5.3.1 安装 SSL 证书 5.3…

使用CyberRT写第一个代码, test ok

简介 计算框架是自动驾驶系统中的重中之重,也是整个系统得以高效稳定运行的基础。为了实时地完成感知、决策和执行,系统需要一系列的模块相互紧密配合,高效地执行任务流。由于各种原因,这些模块可能位于不同进程,也可能位于不同机器。这就要求计算框架中具有灵活的、高性…

谷歌蜘蛛池是什么?

或称为谷歌爬虫池&#xff0c;是一项专门针对谷歌搜索引擎优化&#xff08;SEO&#xff09;的先进技术&#xff0c;这种技术的主要目的是通过建立庞大的网站群体和复杂的链接结构来吸引和维持谷歌的爬虫程序的注意力&#xff0c;其核心是通过这种结构优化&#xff0c;增强特定网…

大学计算机专业三天看完《Python背记手册》全彩版,轻松学会 Python不迷路!

Python作为一门编程语言&#xff0c;Python提供了高效的高级数据结构&#xff0c;还能简单有效地面向对象编程。Python语法和动态类型&#xff0c;以及解释型语言的本质&#xff0c;使它成为多数平台上写脚本和快速开发应用的编程语言&#xff0c;随着版本的不断更新和语言新功…

Java | Leetcode Java题解之第109题有序链表转换二叉搜索树

题目&#xff1a; 题解&#xff1a; class Solution {ListNode globalHead;public TreeNode sortedListToBST(ListNode head) {globalHead head;int length getLength(head);return buildTree(0, length - 1);}public int getLength(ListNode head) {int ret 0;while (head…

20、设计模式之备忘录模式

备忘录模式 备忘录模式&#xff08;Memento Pattern&#xff09;保存一个对象的某个状态&#xff0c;以便在适当的时候恢复对象。备忘录模式属于行为型模式。 介绍 意图&#xff1a; 在不破坏封装性的前提下&#xff0c;捕获一个对象的内部状态&#xff0c;并在该对象之外保存…

【6】PostgreSQL 循环

PostgreSQL 循环 前言笔记WHILE 循环基本结构简单示例详细示例创建示例函数解释调用示例函数预期输出 FOR 循环Numeric FOR Loop基本结构简单示例详细示例创建示例函数解释调用示例函数预期输出 Reverse Numeric FOR Loop基本格式简单示例详细说明创建函数解释调用函数预期输出…

[C][字符串][字符串常用函数介绍]详细讲解

目录 0.前言1.gets2.strlen3.strcpy4.strncpy5.strcat - (效率低)6.strncat7.strcmp8.strncmp9.strstr10.strtok11.strerror12.perror(相对于strerror可能更好用)13.ctype.h14.memcpy15.memmove16.memcmp17.memset18.atoi 0.前言 本篇主要介绍处理字符和字符串的库函数的使用及…