Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the query method of mysql

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "introduction to the query method of mysql". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "introduction to the query method of mysql"!

This article mainly introduces the MySQL slow query analysis method. Some time ago, I set up a record in MySQL to query SQL statements that are slower than 1 second. Remember that there are several ten-point setting methods, and the names of several parameters can not be recalled, so reorganize them and take notes by yourself.

For troubleshooting problems and finding performance bottlenecks, the easiest problems to find and solve are MySQL slow queries and queries that do not have available indexes.

OK, start finding the SQL statements in MySQL that don't "feel good" to execute.

MySQL slow query analysis method 1:

I am using this method, hehe, I prefer this kind of immediacy.

Versions of MySQL5.0 and above can support the recording of slowly executed SQL statements.

# div_code img {border:0px;}

MySQL > show variables like long%

Note: this long_query_time is used to define how many seconds is slower than the "slow query".

# div_code img {border:0px;}

+-+ +

| | Variable_name | Value |

+-+ +

| | long_query_time | 10.000000 | |

+-+ +

1 row in set (0.00 sec)

MySQL > set long_query_time=1

Note: I set 1, that is, if the execution time is more than 1 second, it is a slow query.

# div_code img {border:0px;}

Query OK, 0 rows affected (0.00 sec)

MySQL > show variables like slow%

+-+ +

| | Variable_name | Value |

+-+ +

| | slow_launch_time | 2 | |

| | slow_query_log | ON |

Note: whether to turn on logging

# div_code img {border:0px;}

| | slow_query_log_file | / tmp/slow.log |

Note: where is the setting?

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report