How to know that the SQL statements executed in the database are slow

Source: Internet
Author: User

The website access speed is too slow. We need to check all links that may drag down the website speed, here we will share some of the SQL statements in the database that have been executed with low efficiency to help us better optimize our website programs.

(1) set it in the MySQL configuration file. The specific location is my. ini/my. cnf. Enable MySQL slow query output: log_slow_queries and set its value to ON.

(2) set it on the MySQL client. Connect to the MySQL database server through a client and run the following SQL statement:

Set global log_slow_queries = ON; set global long_query_time = 3;

Here, you can record the SQL statements that take more than or equal to 3 seconds and output them to the log file. You may not know where this log file is stored? Run the following command on the MySQL client:

Show variables like 'slow _ query_log_file ';

The location of the log query file is displayed.

For the above two methods, I personally recommend the second one, because this method does not need to restart the MySQL service. Remember that the first method needs to restart the MySQL service!

Articles you may be interested in
  • Mysql database cache function analysis, debugging, and performance summary
  • MySQL large data volume quick insert method and statement Performance Optimization
  • Summarize the causes and solutions for the slow MySQL Database Server
  • Optimize paging SQL statements for large data volumes in MySQL
  • Improve database performance secret SQL optimization skills
  • Navicat for mysql remote connection to the mySql database prompt 10061,1045 error Solution
  • Steps for synchronizing and backing up mysql Databases in windows
  • Rational use of MySQL database indexes to make the database run efficiently

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.