To do MySQL performance adjustment and service status monitoring, we must know the current running status of MySQL. Many developers have read some articles and analyses on database and table sharding, read-write separation, SQL performance analysis, etc. However, blindly making some MySQL configuration adjustments without considering the actual running status of MySQL is a rough and estimated approach. It may just meet the current actual problem and improve performance, or it may be useless. Therefore, technology should be combined with actual conditions and theories, and cannot be done on paper. This article refers to the official MySQL documentation: server-status-variables Practice View the variables that can be monitored We can use the statement For example, we want to see what MySQL global status indicators are available. mysql> SHOW GLOBAL STATUS; +-----------------------------------+------------+ | Variable_name | Value | +-----------------------------------+------------+ | Aborted_clients | 0 | | Aborted_connects | 0 | | Bytes_received | 155372598 | | Bytes_sent | 1176560426 | ... | Connections | 30023 | | Created_tmp_disk_tables | 0 | | Created_tmp_files | 3 | | Created_tmp_tables | 2 | ... | Threads_created | 217 | | Threads_running | 88 | | Uptime | 1389872 | +-----------------------------------+------------+ If you are only interested in your current connection, you can use If you want to refresh the statistics of status variables, you can use the command
Some key indicator queriesBased on the state variables that can be queried above, I selected several variables for some demonstrations. Query MySQL running time: mysql> show status like 'uptime'; +---------------+--------+ | Variable_name | Value | +---------------+--------+ | Uptime | 398545 | +---------------+--------+ 1 row in set (0.01 sec) Query the number of select executions in MySQL mysql> show global status like 'com_select'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Com_select | 19 | +---------------+-------+ 1 row in set (0.01 sec) Query the number of insert executions in MySQL mysql> show status like 'com_insert'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Com_insert | 0 | +---------------+-------+ 1 row in set (0.00 sec) Query the number of update executions in MySQL mysql> show status like 'com_update'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Com_update | 0 | +---------------+-------+ 1 row in set (0.00 sec) Query the number of delete executions in MySQL mysql> show status like 'com_delete'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Com_delete | 0 | +---------------+-------+ 1 row in set (0.00 sec) The above CRUD count can be directly used as the basis for actual MySQL performance optimization. For example, the memory allocation strategy can be adjusted according to the ratio of reads and writes. Query connection times mysql> show status like 'connections'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Connections | 286 | +---------------+-------+ 1 row in set (0.00 sec) Query the number of slow queries mysql> show status like 'slow_queries'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Slow_queries | 0 | +---------------+-------+ 1 row in set (0.00 sec) Query slow query time (default 10 seconds) mysql> show variables like 'long_query_time'; +-----------------+-----------+ | Variable_name | Value | +-----------------+-----------+ | long_query_time | 10.000000 | +-----------------+-----------+ 1 row in set (0.01 sec) In fact, there are many indicators. When you encounter actual problems, you can query them in a targeted manner and adjust MySQL parameters based on these data. The above is the detailed content of the use of MySQL SHOW STATUS statement. For more information about MySQL SHOW STATUS, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Web design tips on form input boxes
>>: How to implement responsiveness in Vue source code learning
Table of contents 1. Project environment: 2: DNS ...
The MySQL version number is 5.7.28. Table A has 3...
Docker is becoming more and more popular. It can ...
Preparation: 192.168.16.128 192.168.16.129 Two vi...
Preface In daily development, when we use MySQL t...
Correct answer Using useRouter : // router path: ...
1. Background Use LDAP to centrally manage operat...
This article describes how to compile and install...
I've been playing with the remote development...
This article will introduce how to use radial-gra...
What are XHTML tags? XHTML tag elements are the b...
1. Get the real path of the current script: #!/bi...
Omit the protocol of the resource file It is reco...
1. Command Introduction The date command is used ...
Overview of Alibaba Cloud Security Group Sharing ...