Get the App
SLTechnology News&Howtos  ›  Database  › 

How Mysql uses profile to analyze sql overhead

Shulou Source: shulou.com Published: 2022-06-01 02:31:20 10月04日 Update

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!

Tags: Analysis overhead variables time version article instructions information functions fields done performance effects data database number more knowledge spaces system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Information Shulou Tech Info Huawei OPPO Reno