【MySQL】show global status命令
show global status是MySQL中一条重要的命令,它可以用来查询MySQL当前状态。通过这个命令,可以了解当前系统的运行状态和性能瓶颈。
show global status返回的结果包括一个记录所有MySQL服务器已经处理的请求数量的计数器和所有已经执行的各种操作的计数器。这些计数器统计的包括会话级别的和全局级别的,可以帮助DBA监控MySQL的性能,并且及时调整参数以优化MysQL。
下面是show global status的使用方法:
SHOW GLOBAL STATUS [LIKE 'pattern']
其中,\pattern\是模糊匹配的字符串,用于查询特定计数器的值。如果没有指定\pattern\,则返回MySQL中所有计数器的值。
下面是show global status返回的结果中常见计数器的含义:
| Variable_name | Description |
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| Aborted_clients | Number of connections that were aborted because the client died without closing the connection properly. |
| Aborted_connects | number of times TCP/IP connections to sql server was aborted |
| Bytes_received | Number of bytes received from all clients. |
| Bytes_sent | Number of bytes sent to all clients. |
| Com_create_table | Number of \CREATE TABLE\ statements executed by the server. |
| Com_select | Number of \SELECT\ statements executed by the server. |
| Connections | Number of connections to the server since it started. |
| Created_tmp_disk_tables | Number of temporary tables on disk created automatically by the server while executing statements. |
| Created_tmp_files | Number of temporary files created by the server. |
| Created_tmp_tables | Number of temporary tables created by the server while executing statements. |
| Innodb_buffer_pool_hit_rate | ratio of the number of pages that were found in the buffer pool to the number of pages requested by queries using the InnoDB storage engine |
| Innodb_buffer_pool_reads | Number of logical reads that the InnoDB buffer pool could not satisfy from memory and had to do a read from disk. |
| Innodb_buffer_pool_write_requests | Number of write requests to the InnoDB buffer pool. |
| Innodb_buffer_pool_writes | Number of pages written to the InnoDB buffer pool. |
| Innodb_data_reads | Number of data reads from InnoDB data files. |
| Innodb_data_writes | Number of data writes to InnoDB data files. |
| Innodb_row_lock_time_avg | Time to acquire a row lock, averaged over all row locks waited for. |
| Innodb_row_lock_time_max | Maximum time to acquire a row lock. |
| Innodb_row_lock_waits | Number of times a row lock had to be waited for. |
| Innodb_rows_read | Number of rows read from InnoDB tables. |
| Innodb_rows_updated | Number of rows updated in InnoDB tables. |
| Key_read_requests | Number of requests to read an index block from the key cache. |
| Key_reads | Number of index blocks read from the key cache. |
| Key_write_requests | Number of requests to write an index block to the key cache. |
| Key_writes | Number of index blocks written to the key cache. |
| Qcache_hits | Number of query cache hits. |
| Qcache_inserts | Number of queries added to the query cache. |
| Qcache_not_cached | Number of non-cached queries |
| Qcache_lowmem_prunes | Number of queries removed from the query cache because of low memory, |
| Questions | Number of statements executed by the server. |
| Slow_queries | Number of queries that have taken more than long_query_time seconds to execute. |
| Table_locks_immediate | Number of times a table lock was acquired immediately. |
| Table_locks_waited | Number of times a table lock could not be immediately acquired and a wait was needed. |
| Threads_connected | Number of currently open connections. |
| Threads_created | Number of threads created to handle connections. |
| Uptime | Time in seconds that the server has been up. |
通过show global status命令,可以帮助DBA了解MySQL的性能和瓶颈,从而可以修改相应配置并进行优化。
