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

How Mysql uses profile to analyze sql overhead

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

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how Mysql uses profile to analyze sql overhead. I hope you will learn a lot after reading this article. Let's discuss it together.

Mysql uses profile to analyze sql overhead

1. Check the version information of the current database before using it. The lower version cannot be used. Show version (); or show variables like'% version%'2. View profiling show variables like'% profil%' Result: +-+-+ | Variable_name | Value | +-+-+ | have_profiling | YES |-- read-only variable Used to control whether profiling is enabled or disabled by the system variable | profiling | OFF |-- enable the parsing function of SQL statements | profiling_history_size | 15 |-set the number of reserved profiling. Default is 15, range is 0 to 100. if 0, p show profiles is disabled. Check whether it is turned on, and the effect is the same as above. 3. Check the instructions for help profile;4. Do not have extra spaces when turning on profile set profiling=1; assignment. 5. Run sql to view the corresponding profile select * from test; show profiles Result: + -- + | Query_ID | Duration | Query | +- +- -+ | 28 | 0.00033575 | select * from test | +- -+ analyze sql performance You can add the corresponding cost field show profile [cpu,io] [all] for query 28 when analyzing. Show profile for query 28 +-- +-+ | Status | Duration | +-+-+ | starting | 5.7E-5 | | checking permissions | 7E-6 | | Opening tables | 1.7E-5 | | init | 2.3E-5 | | System lock | 8E-6 | | optimizing | 5E-6 | | statistics | 1.1E-5 | | preparing | 9E-6 | | executing | 3E-6 | | Sending data | 8.8E-5 | | | end | 5E-6 | | query end | 6E-6 | | closing tables | 5E-6 | | freeing items | 7.8E-5 | | cleaning up | 1.5E-5 | +-- +-+ 6. After reading this article after closing set profiling=off;, I believe you have some understanding of how Mysql uses profile to analyze sql overhead. If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

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