Analysis of SQL statement execution time and resource consumption using profilessql

Source: Internet
Author: User

Analysis of SQL statement execution time and resource consumption using profilessql

Open profiling, which is disabled by default.

mysql> set profiling=1;

Execute the SQL statement to be analyzed

mysql> select count(1) from wechat_employee,Employee;

Show profiles table

mysql> show profiles;

Query results:

+----------+------------+-----------------------------------------------+| Query_ID | Duration   | Query                                         |+----------+------------+-----------------------------------------------+|        1 | 0.00072975 | select count(1) from wechat_employee,Employee ||        2 | 0.00028450 | set profiling=1                               ||        3 | 0.00324875 | select count(1) from wechat_employee,Employee |+----------+------------+-----------------------------------------------+

Query details:

show profile cpu,block io for query 3;

Result:

+--------------------------------+----------+----------+------------+--------------+---------------+| Status                         | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |+--------------------------------+----------+----------+------------+--------------+---------------+| starting                       | 0.000041 | 0.000000 |   0.000000 |            0 |             0 || Waiting for query cache lock   | 0.000073 | 0.000000 |   0.000000 |            0 |             0 || checking query cache for query | 0.000025 | 0.000000 |   0.000000 |            0 |             0 || checking privileges on cached  | 0.000023 | 0.000000 |   0.000000 |            0 |             0 || checking permissions           | 0.000018 | 0.000000 |   0.000000 |            0 |             0 || checking permissions           | 0.000012 | 0.000000 |   0.000000 |            0 |             0 || sending cached result to clien | 0.003009 | 0.000000 |   0.004000 |            0 |             0 || logging slow query             | 0.000032 | 0.000000 |   0.000000 |            0 |             0 || cleaning up                    | 0.000018 | 0.000000 |   0.000000 |            0 |             0 |+--------------------------------+----------+----------+------------+--------------+---------------+9 rows in set (0.00 sec)

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.