Detailed time profile for SQL query execution

Source: Internet
Author: User

1. View profile settings

  SHOW VARIABLES like '%profil% '

The results are as follows: profiling off

2. Open profile

  SET Profiling=1

Results:

3. Execute the SQL you want to execute

Explain select* ...

4. Query execution of SQL

  SHOW PROFILES

Results:

5. View the required SQL execution details

   for 308

Results:

   for 308

Results:

   All  for 308

Results:

Status

Hecking table

Checking the data table (this is automatic).

Closing tables

The modified data in the table is being flushed to disk, and the tables that have been exhausted are being closed. This is a quick operation, and if not, you should confirm that the disk space is full or that the disk is under heavy load.

Connect out

Replication from the server is connecting to the primary server

Copying to TMP table on disk

Saving memory by converting temporary tables from memory storage to disk storage because the temporary result set is larger than tmp_table_size

Creating tmp table

Creating temporary tables to hold partial query results

deleting from Main Table

The server is performing the first part of a multi-table delete and has just deleted the first table.

deleting from reference tables

The server is performing the second part of a multi-table delete and is deleting records from other tables.

Flushing tables

Executing FLUSH TABLES, waiting for other threads to close the data table

Killed

Sends a KILL request to a thread, the thread checks the kill flag bit and discards the next kill request. MySQL checks the kill flag bit in each of the main loops, but in some cases the thread may die in a short period of time. If the line regulation regulation is locked by another thread, the kill request will take effect as soon as the lock is released.

Locked

Locked up by another query.

Sending data

Processing record for SELECT query while sending results to client

Sorting for group

Sorting for GROUP by

Sorting for order

Sorting for ORDER BY

Opening tables

The process should be quick, unless other factors interfere with it. For example, a data table cannot be opened by another thread until the row of the ALTER table or LOCK table statement is complete. Trying to open a table

removing duplicates

A query that is executing a SELECT DISTINCT method is being executed, but MySQL cannot optimize those duplicate records in the previous phase. Therefore, MySQL needs to remove the duplicate records again, and then send the results to the client

Reopen table

A lock on a table is obtained, but it must be changed after the table structure has been modified. The lock has been released, the data table is closed, and the data table is attempting to reopen

Repair by sorting

Repair instructions are being sorted to create an index

Repair with Keycache

The repair instructions are using the index cache to create a new index one by one. It'll be slower than Repair by sorting.

Searching rows for update

The qualifying records are being told to find out to prepare for the update. It must be completed before the UPDATE will modify the relevant records.

Sleeping

Waiting for client to send new request

System Lock

Is waiting to get an external system lock. If you are not currently running multiple mysqld servers requesting the same table at the same time, you can suppress the external system lock by adding the--skip-external-locking parameter

Upgrading lock

Insert DELAYED is trying to get a lock table to insert a new record

Updating

Searching for matching records, and modifying them

User Lock

Waiting for Get_lock ()

Waiting for tables

The thread is notified that the data table structure has been modified and the data table needs to be reopened to obtain a new structure. Then, to be able to reopen the data table, you must wait until all other threads close the table. This notification is generated in the following cases: FLUSH TABLES tbl_name, ALTER table, RENAME table, REPAIR table, ANALYZE table, or OPTIMIZE table

Waiting for handler insert

Insert DELAYED has processed all pending inserts and is waiting for a new request

6. Close Profile Analysis

  SET Profiling=0

Results:

Detailed time profile for SQL query execution

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.