Use of mysql benchmark Function

Source: Internet
Author: User

The following describes the syntax of the mysql benchmark function and some tests on the mysql benchmark function.

 
 
  1. BENCHMARK (count, expr)
  2. The BENCHMARK () function repeats the countTimes execution expression expr, which can be used to time how fast the MySQL processing expression is. The result value is always 0. Intended for mysql customers, it reports the query execution time.
  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 report time is the client time, not the CPU time on the server. It may be wise to execute BENCHMARK () several times, and note that the server load has to be explained again.

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

As long as we set the count parameter to a greater value, the execution time will become longer. Next we will look at the effect of execution in mysql:

 
 
  1. Mysql> select md5 ('test ');
  2. + ---------------------------------- +
  3. | Md5 ('test') |
  4. + ---------------------------------- +
  5. | 098f6bcd4621d373cade4e832627b4f6 |
  6. + ---------------------------------- +
  7. 1 row in set (0.00 sec) <----------- the execution time is 0.00 sec
  8.  
  9. Mysql> select benchmark (500000, md5 ('test '));
  10. + ------------------------------------ +
  11. | Benchmark (500000, md5 ('test') |
  12. + ------------------------------------ +
  13. | 0 |
  14. + ------------------------------------ +
  15. 1 row in set (6.55 sec) <------------ the execution time is 6.55 sec

It can be seen that the time for executing 500000 times with benchmark is significantly longer than the normal execution time.

The preceding section describes how to use the mysql benchmark function.

Mysql Aggregate functions

MySQL string case-sensitive Conversion Function

Use of the concat_ws function in MySQL

Syntax for creating a Mysql trigger

Implementation of MySql remote connection

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.