MySQL find SQL time-consuming bottleneck SHOW profiles

Source: Internet
Author: User

http://blog.csdn.net/k_scott/article/details/8804384

1. First check whether the profiling function is turned on [SQL]View PlainCopy
    1. SHOW VARIABLES like '%pro% ';

Or

[SQL]View PlainCopy
    1. SELECT @ @profiling;


2. Open Profiling

[SQL]View PlainCopy
    1. SET profiling=1;

3. Execute SQL statements

For example:

[SQL]View PlainCopy
    1. select   
    2.   table_schema as  ' Db name ',  
    3.   round ( sum ( data_length +  index_length )  / 1024 / 1024, 3 )  as  ' db size  (MB) ',   
    4.   round ( sum ( data_free )  / 1024 / 1024,  3 )  as  ' free space  (MB) '   
    5. from information_schema.tables   
    6. group by table_schema ;   

4. View Results

[SQL]View PlainCopy
    1. SHOW profiles;
[SQL]View PlainCopy
    1. SHOW profile all for QUERY 94;

94 is the query ID number.

SHOW Profiles Syntax:

[SQL]View PlainCopy
    1. SHOW profile [Type [, type] ...]
    2. [ForQUERY N]
    3. [LIMIT row_count [offset offset]]
    4. Type
    5. All
    6. | BLOCK IO
    7. | CONTEXT Switches
    8. | Cpu
    9. | Ipc
    10. | MEMORY
    11. | PAGE faults
    12. | SOURCE
    13. | SWAPS



MySQL find SQL time-consuming bottleneck SHOW profiles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.