The use of MYSQL benchmark functions

Source: Internet
Author: User
Tags benchmark

MYSQL benchmark function is one of the most important functions, the use of the function is analyzed in detail below, if you are interested in this, you may wish to see.

The following is a description of the MySQL benchmark function syntax, and some of the MySQL benchmark function related questions to test, for your reference to learn.

    1. BENCHMARK (count,expr)
    2. The BENCHMARK () function repeats counttimes execution of the expression expr, which can be used to time how fast the MySQL processing expression is. The result value is always 0. Intended for MySQL clients, it reports the execution time of the query.
    3. MySQL> select BENCHMARK (1000000,encode ("Hello", "Goodbye"));
    4. +----------------------------------------------+
    5. | BENCHMARK (1000000,encode ("Hello", "Goodbye")) |
    6. +----------------------------------------------+
    7. | 0 |
    8. +----------------------------------------------+
    9. 1 row in Set (4.74 sec)

The reported time is the client's elapsed time, not the CPU time on the server side. It may be advisable to execute benchmark () several times, and note that the load on the server machine is multiple to interpret the results.

--------------------------------------------------------------------------------

As long as we set the parameter count to a larger point, the execution time will be longer. Let's take a look at the effect in MySQL:

  1. MySQL> select MD5 (' Test ');
  2. +----------------------------------+
  3. | MD5 (' Test ') |
  4. +----------------------------------+
  5. | 098f6bcd4621d373cade4e832627b4f6 |
  6. +----------------------------------+
  7. 1 row in Set (0.00 sec)-----------Execution Time is 0.00 sec
  8. MySQL> select benchmark (500000, MD5 (' Test '));
  9. +------------------------------------+
  10. | Benchmark (500000, MD5 (' Test ')) |
  11. +------------------------------------+
  12. | 0 |
  13. +------------------------------------+
  14. 1 row in Set (6.55 sec)------------Execution Time is 6.55 sec

This shows that the time to execute 500,000 times with benchmark is significantly longer than the normal execution time.

The above is an introduction to the use of MySQL benchmark functions.

The use of MYSQL benchmark functions

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.