How Do I Query SQL Statements in MySQL that Are Executed with Inefficient Execution?

Updated on technology 2024-02-08
2 answers
  1. Anonymous users2024-02-05

    1. MySQL database has several configuration options that can help us capture inefficient SQL statements in a timely manner1, Slow Query Log

    If this parameter is set to on, you can capture SQL statements whose execution time exceeds a certain value.

    2,long_query_time

    If the execution time of an SQL statement exceeds this value, it will be recorded in the log, and it is recommended that you set it to 1 or shorter.

    3. The file name of the slow query log file.

    4. If the log queries not using indexes parameter is set to on, it can capture all SQL statements that do not use indexes, although this SQL statement may be executed quite quickly.

    2. Methods to detect the efficiency of SQL statements in MySQL 1.

    1) Open MySQL under Windows and query the MySQL configuration file in the Windows system is generally to find [MysqlD] and add it below.

    **As follows. log-slow-queries = f:/mysql/log/long_query_time = 2

  2. Anonymous users2024-02-04

    You can use MySQL's built-in slow log analysis tool to query SQL statements that are inefficient in MySQL. Log is a file written by MySQL based on the execution time of SQL statements to analyze slow statements.

    The configuration method is as follows:

    1. Open the MySQL installation directory, find the file, open it, and enter the following configuration:

    log-slow-queries = [slow_query_log_filename]

    You can record SQL statements that exceed the default 10s execution time.

    If you want to modify the default settings, you can add:

    long_query_time = 5

    Set to 5s.

    2. In the process of SQL execution, use explain to understand the status of SQL execution.

    Explain shows how MySQL uses indexes to handle select statements and join tables. It can help you select better indexes and write more optimized query statements.

    To use it, add explain before the select statement

    For example, explain select surname, first name form a, b where

Related questions
3 answers2024-02-08

2009-07-17 18:10 [Zhejiang Hangzhou Nanxingqiao Company] receiver [Yuan Zhongkui] has been received. >>>More

2 answers2024-02-08

Waybill number Date Departure station Destination Number of pieces Signatory Signatory Signature time Signing**. >>>More

2 answers2024-02-08

Waybill number Date Departure station Destination Number of pieces Signatory Signatory Signature time Signing**. >>>More

7 answers2024-02-08

If you accidentally delete the files, chat history, and contacts stored in the internal memory without backing up the data in advance, the deleted files and contacts cannot be recovered. Therefore, it is recommended that you carefully delete the data on your phone, and back up your files in time if possible, so as to avoid the loss of important data and cannot be retrieved.

6 answers2024-02-08

Waybill number, date, departure station, destination, number of pieces, signatory, signature time. >>>More