In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Mysql gets the execution plan method:
1. View the execution plan of sql through explain
two。 View the execution plan of the sql through the sql that the thread is executing
It is relatively easy for explain to view the execution plan of sql, and it is also very easy to view the execution plan through the sql that the thread is executing, so why do you need a second way? Because daily work will find that a lot of sql is executing all the time, and there is an exception in execution, if we take out the sql and execute it very quickly, we want to get the execution plan of the sql when the execution is abnormal. At the same time, because the data changes from time to time, the statistical information may also change, which may lead to a change in the execution plan. Fortunately, mysql5.7 can already view the execution plan of the sql through the thread that is executing. You don't need to take out the sql to execute the acquisition execution plan, so you can restore the truth very well:
Show processlist; or select * from information_schema.PROCESSLIST where info is not null order by time desc; check.
Mysql > select from information_schema.PROCESSLIST where info is not null
+- -- +
| | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |
+- -- +
| | 17 | root | localhost | NULL | Query | 0 | executing | select from information_schema.PROCESSLIST where info is not null | |
| | 178 | root | localhost:60124 | app1 | Query | 560 | Sending data | select count (*) from t, t_adress where t.adress = t_adress.adress |
+- -- +
2 rows in set (0.00 sec)
Mysql > EXPLAIN FOR CONNECTION 178
+- -- +
| | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+- -- +
| | 1 | SIMPLE | t_adress | NULL | ALL | NULL | NULL | NULL | NULL | 200096 | 100.00 | NULL |
| | 1 | SIMPLE | t | NULL | ALL | NULL | NULL | NULL | NULL | 309664 | 100.00 | Using where; Using join buffer (Block Nested Loop) |
+- -- +
2 rows in set (0.01sec)
Isn't it convenient to use?
One last word:
I feel very suffocated today. I went to sleep.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.