MySQL show processlist display mysql query process _mysql

Source: Internet
Author: User
Tags flush mysql query sleep mysql view
1. Enter the Mysqladmin processlist into the Mysql/bin catalogue;
2. Start MySQL, enter show Processlist;
If you have SUPER permissions, you can see all of the threads, otherwise you can only see the thread that you originated (this is the current corresponding MySQL account running thread).
The data forms are as follows (only three are intercepted):
Mysql> show Processlist;
+-----+-------------+--------------------+-------+---------+-------+----------------------------------+-------- --
| Id | User | Host | db | Command | time| State | Info
+-----+-------------+--------------------+-------+---------+-------+----------------------------------+-------- --
|207|root |192.168.0.20:51718 |mytest | Sleep | 5 | | Null
|208|root |192.168.0.20:51719 |mytest | Sleep | 5 | | Null
|220|root |192.168.0.20:51731 |mytest | Query | 84 | Locked |
Select Bookname,culture,value,type from book where id=001
First of all, the meaning and use of the columns, the first column, ID, needless to say, a logo, you want to kill a statement when it is useful. The user column, which displays a single user, and if not root, this command displays only the SQL statements within your purview. The host column, which indicates which IP port the statement is issued from. Oh, can be used to track the user of the problem statement. DB column that shows which database the process is currently connected to. Command column, which displays commands for the execution of the current connection, generally hibernation (sleep), queries (query), connection (connect). Time column, which is the duration of this state, in seconds. State column, which shows the status of the SQL statement using the current connection, a very important column, followed by a description of all States, note that State is only one of the States in the execution of the statement, an SQL statement, a query as an example, may need to go through copying to TMP table, Sorting result,sending data can be completed, info column, display this SQL statement

If you perform additions and deletions in a large-capacity table or execute a complex SQL query, the MySQL thread hangs. Use this command to find out which SQL hangs, and remove him with the kill command.

Kill command Use Method

Kill PID

As in the example above, we want to kill the thread with ID 207 to execute

Kill 207.

MySQL show processlist command detailed


Show Processlist shows which threads are running. You can also use the Mysqladmin processlist statement to get this information. If you have super privileges, you can see all threads. Otherwise, you will only see your own thread (that is, the thread associated with the MySQL account you are using ). See section 13.5.5.3, "kill syntax." If you do not use full keywords, only the first 100 characters of each query are displayed .

This statement reports the host name of the TCP/IP connection (in host_name:client_port format) to easily determine what client is doing.

This statement is useful if you get the "Too many connections" error message and want to know what is happening. MySQL retains an additional connection that allows the account with super privileges to be used to ensure that the administrator can connect and check the system at any time (assuming you do not give this permission to all users).

The most critical of this command is the State column, which is listed in the following categories:

Checking Table
Checking the datasheet (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 make sure that the disk space is full or if the disk is in a heavy load.
Connect out
Replication is connecting to the primary server from the server.
copying to TMP table on disk
Because the temporary result set is greater than tmp_table_size, the temporary table is being converted from memory storage to disk storage to save memory.
Creating TMP Table
A temporary table is being created to hold some of the query results.
deleting from Main Table
The server is performing the first part of a multiple table deletion and just deleted the first table.
Deleting from reference tables
The server is performing the second part of a multiple table deletion and is deleting records from other tables.
Flushing tables
Executing flush tables, waiting for other threads to close the datasheet.
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 the main loop each time, but in some cases the thread may die a short time. If the line Chengcheng is locked by another thread, the kill request takes effect as soon as the lock is released.
Locked
was locked by another query.
Sending Data
A record of a select query is being processed and the results are being sent to the client.
Sorting for Group
Sorting GROUP BY.
Sorting for order
Ordering by is being sorted.
Opening Tables
This process should be quick unless it is interfered by other factors. For example, a datasheet cannot be opened by another thread until the ALTER TABLE or LOCK table statement is done. Trying to open a table.
Removing duplicates
A SELECT DISTINCT query is being executed, but MySQL cannot optimize those duplicate records in the previous phase. Therefore, MySQL needs to remove duplicate records again, and then send the results to the client.
Reopen Table
A lock on a table is obtained, but the lock must be acquired after the table structure has been modified. The lock has been released, the datasheet is closed, and an attempt is being made to reopen the data table.
Repair by sorting
The repair instructions are being sorted to create an index.
Repair with Keycache
The repair instruction is using the index cache to create a new index one by one. It will be slower than repair by sorting.
Searching rows for update
The qualifying records are being identified for updating. It must be completed before update is required to modify the relevant records.
Sleeping
Waiting for client to send new request.
System Lock
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 prevent external system locks by adding--skip-external-locking parameters.
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 datasheet structure has been modified and that the data table needs to be reopened to obtain a new structure. Then, in order to be able to reopen the datasheet, you must wait until all other threads close the table. This notification is generated in the following situations: FLUSH TABLES tbl_name, ALTER TABLE, RENAME table, REPAIR table, ANALYZE table, or optimize table.
waiting for handler insert
Insert delayed has finished processing all pending inserts and is waiting for a new request.
Most of the state corresponds to a quick operation, as long as a thread remains in the same state for several seconds, then there may be a problem that needs to be checked.
There are other states that are not listed above, but most of them are only useful if they are looking at the server for errors.

MySQL view current number of connections

Command: Show Processlist;
If it is the root account, you can see the current connection for all users. If it's another normal account, you can only see the connection you're using.
Show Processlist only list the first 100, if you want to list all please use show full processlist;
Mysql> show Processlist;

Order: Show status;

Aborted_clients the number of connections that have been dropped because the customer has not properly shut down the connection already dead.
Aborted_connects the number of attempts to connect to a MySQL server that has failed.
Connections the number of attempts to connect to the MySQL server.
Created_tmp_tables the number of hidden temporary tables that have been created when the statement is executed.
Delayed_insert_threads the number of deferred insert processor threads being used.
Delayed_writes the number of rows written with insert delayed.
Delayed_errors the number of rows in which some errors (possibly duplicate key values) were written with insert delayed.
Flush_commands the number of times the Flush command was executed.
The number of times the Handler_delete request deletes rows from a table.
Handler_read_first the number of times the first row in the table is requested to be read.
The Handler_read_key request number is based on the key read line.
The number of times a handler_read_next request reads in a row based on a key.
The number of times a HANDLER_READ_RND request reads a row based on a fixed position.
Handler_update the number of times a row in the table was requested to be updated.
The number of times the Handler_write request inserts a row into the table.
key_blocks_used the number of blocks used for the keyword cache.
Key_read_requests the number of times a key value is requested to be read from the cache.
Key_reads the number of times a key value is physically read from disk.
Key_write_requests request to write a key block to the cache count.
Key_writes the number of times a key-value block is physically written to disk.
The maximum number of connections that the max_used_connections uses at the same time.
Not_flushed_key_blocks a key block that has been changed in the key cache but has not been emptied to disk.
Not_flushed_delayed_rows the number of rows waiting to be written in the Insert delay queue.
Open_tables the number of tables opened.
Open_files the number of open files.
Number of Open_streams open streams (mainly for log records)
Opened_tables the number of tables already open.
Questions the number of queries sent to the server.
Slow_queries the number of queries to spend more than long_query_time time.
threads_connected the number of connections currently open.
Threads_running the number of threads that are not sleeping.
How many seconds the Uptime server worked.

After create

This is occurs when the thread creates a table (including internal temporary tables) and at the "end of" the function that creates The table. This is used even if the table could does not are created due to some error.

Analyzing

The thread is calculating a MyISAM table key distributions (for example, for ANALYZE table).

Checking permissions

The thread is checking whether the server has the required privileges to execute the statement.

Checking table

The thread is performing a table check operation.

Cleaning up

The thread has processed one command and is preparing to free memory and reset certain state variables.

Closing tables

The thread is flushing the used tables of the changed table data to disk and closing. This should is a fast operation. If not, you should verify so you don't have a full disk and that's the disk is no in very heavy use.

Converting HEAP to MyISAM

The thread is converting a internal temporary table from a MEMORY table to a on-disk MyISAM table.

Copy to TMP table

The thread is processing a ALTER TABLE statement. This state occurs after the table with the new structure has been created but before rows are into it.

Copying to Group table

If A statement has different order by and group by criteria, the rows are sorted from GROUP and copied to a temporary table.

Copying to TMP table

The server is copying to a temporary table in memory.

Copying to TMP table on disk

The server is copying to a temporary table on disk. The temporary result set was larger than tmp_table_size and the thread are changing the temporary table from in-memory to D isk-based format to save memory.

Creating index

The thread is processing ALTER TABLE ... ENABLE KEYS for a MyISAM table.

Creating sort Index

The thread is processing a SELECT this is resolved using a internal temporary table.

Creating table

The thread is creating a table. This includes creation of temporary tables.

Creating TMP Table

The thread is creating a temporary table with memory or on disk. If The table is created in memory but later are converted to a On-disk table, the state during that operation would be Copy ing to TMP table on disk.

deleting from Main Table

The server is executing the ' a multiple-table delete. It is deleting only from the "the", and saving columns and offsets to being used for deleting ) tables.

deleting from reference tables

The server is executing the second part of a multiple-table deletes and deleting the matched rows from the other tables.

Discard_or_import_tablespace

The thread is processing a ALTER TABLE ... Discard tablespace or ALTER TABLE ... IMPORT tablespace statement.

End

This is occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.

Executing

The thread has begun executing a statement.

Execution of Init_command

The thread is executing statements in the value of the Init_command system variable.

Freeing items

The thread has executed a command. This was usually followed by cleaning up.

Flushing tables

The thread is executing FLUSH tables and are waiting for all threads to close their tables.

Fulltext initialization

The server is preparing to perform a natural-language full-text search.

Init

This occurs before the initialization of ALTER TABLE, DELETE, INSERT, SELECT, or UPDATE statements.

Killed

Someone has sent a kill statement to the thread and it should abort next time it checks the kill flag. The flag is checked in each major loop in MySQL, but in some cases it might still take a short time for the thread to die. If the thread is locked by some other thread, the kill takes effect as soon as the other thread releases its lock.

Locked

The query is locked by another query.

Logging Slow Query

The thread is writing a statement to the Slow-query log.

Null

This is used to the show processlist state.

Login

The initial state for a connection thread until the client has been authenticated.

Opening Tables, Opening table

The thread is trying to open a table. This is should to very fast procedure, unless something prevents. For example, an ALTER table or a LOCK table statement can prevent opening a table until the statement is finished.

Preparing

This state occurs during query optimization.

Purging Old relay logs

The thread is removing unneeded relay log files.

Query end

This state occurs after processing a query but before the freeing items state.

Reading from net

The server is reading a packet from the network.

removing duplicates

The query is using SELECT DISTINCT in such a way which MySQL could not optimize away the DISTINCT operation at a early St Age. Because of this, MySQL requires a extra stage to-remove all duplicated rows before sending the "result" to the client.

removing TMP table

The thread is removing a internal temporary table after processing a SELECT statement. This isn't used if no temporary table is created.

Rename

The thread is renaming a table.

Rename result table

The thread is processing a ALTER table statement, has created the new TABLE, and is renaming it to replace the original T Able.

Reopen tables

The thread got a lock for the table, but noticed after getting the lock this underlying table structure changed. It has freed the lock, closed the table, and is trying to reopen it.

Repair by sorting

The repair code is using a sort to create indexes.

Repair Done

The thread has completed a multi-threaded repair for a MyISAM table.

Repair with Keycache

The repair code is using creating keys one by one through the key cache. This is very slower than Repair by sorting.

Rolling back

The thread is rolling back a transaction.

Saving state

For MyISAM table operations such as repair or analysis, the thread are saving the new table state to the. Myi file header. State includes information such as number of rows, the auto_increment counter, and key distributions.

Searching rows for update

The thread is doing a-phase to find all matching rows before updating them. This has to being done if the ' UPDATE is ' changing the ' index ' is used to find the involved rows.

Sending data

The thread is processing rows for a SELECT statement and also are sending data to the client.

Setup

The thread is beginning a ALTER TABLE operation.

Sorting for group

The thread is doing a sort to satisfy a GROUP by.

Sorting for order

The thread is doing a sort to satisfy an order by.

Sorting index

The thread is sorting index pages for more efficient access during a MyISAM table optimization operation.

sorting result

For a SELECT statement that is similar to creating sort index, but for nontemporary tables.

Statistics

The server is calculating statistics to develop a query execution plan.

System Lock

The thread is going to request or are waiting for a internal or external system lock for the table. If this is being caused by requests to external locks and you are not using multiple MYSQLD servers that are access ing the same tables, you can disable External system locks with the--skip-external-locking option. However, external locking is disabled by default, and so it is likely to this option would have no effect. For show profiles, this state means the thread was requesting the lock (not waiting for it).

Table Lock

The next thread state after System lock. The thread has acquired an external lock and are going to request a internal table lock.

Updating

The thread is searching for rows to update and is updating them.

Updating Main Table

The server is executing the ' a multiple-table update. It is updating only the "only", and saving columns and offsets to being used for updating of the other (reference) tables.

Updating reference tables

The server is executing the second part of a multiple-table update and updating the matched rows from the other tables.

User Lock

The thread is going to request or are waiting for a advisory lock requested with a get_lock (). For show profiles, this state means the thread was requesting the lock (not waiting for it).

Waiting for tables, waiting for table

The thread got a notification that's underlying structure for a table has changed and it needs to reopen the table to GE t the new structure. However, to reopen the table, it must wait until all other threads have closed the table in question.

This notification takes place if another thread has used FLUSH TABLES or one of the following on the table in Q Uestion:flush TABLES tbl_name, ALTER table, RENAME table, REPAIR table, ANALYZE table, or OPTIMIZE table.

Waiting on cond

A generic state in which the thread are waiting for a condition to become true. No specific state information is available.

Writing to Net

The server is writing a packet to the network.

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.