MySQL Database show processlist results analysis

Source: Internet
Author: User
Tags flush sleep first row create database

Mysql> show Processlist;

+-–+ ————-+ —————— –+

| Id | User | Host | db | Command | time| State | Info

+-–+ ————-+ —————— –+

|207|root |192.168.0.2:51621 |mytest | Sleep | 5 | | Null

|208|root |192.168.0.2:51622 |mytest | Sleep | 5 | | Null

|220|root |192.168.0.2:51676 |mytest | Query | 84 | Locked |

Select Name,culture,value,type from book where id=1

Describe the meaning and purpose of each column,

ID column: An identifier that is useful when you want to kill a statement.

User column: Displays the current user, and if not root, this command displays only the SQL statements within your purview.

Host column: Shows which IP port this statement is issued from. A user that can be used to track a problem statement.

DB column: Shows which database the process is currently connected to.

Command column: Commands that display the execution of the current connection, typically hibernation (sleep), queries (query), connection (connect).

Time column: This is the duration of this state, in seconds.

State column: Displays 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 state in the execution of the statement, an SQL statement, a query for example, may need to go through copying to TMP table, Sorting result,sending data and so on to complete the state.

Info column: Displays this SQL statement, because the length is limited, so the long SQL statement is not complete, but an important basis for judging the problem statement.

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.


Additional details of the MySQL show command are available for inspection:

Show tables or show tables from database_name or show database_name.tables;
Explanation: Displays the names of all tables in the current database
show databases;
Explanation: Displays the names of all the databases in MySQL

Show Processlist;
Explanation: Displays all processes running on the system, which are currently executing queries. Most users can view
Their own processes, but if they have process permissions, they can view all of the processes, including passwords.

Show table status;
Explanation: Displays information about each table in the currently used or specified database. Information includes the latest update times for table types and tables



Show columns from table_name to database_name; or show columns from database_name.table_name; or show fields;
Explanation: Displays the column names in the table (the same effect as the DESC table_name command)

Show grants for User_name@localhost;
Explanation: Displays the permissions of a user, displaying the results similar to the grant command

Show index from TABLE_NAME; or show keys;
Explanation: Displays the index of the table

Show status;
Explanation: Displays information about some system-specific resources, such as the number of threads running

Show variables;
Explanation: Displays the name and value of the system variable

Show privileges;
Explanation: Displays the different permissions supported by the server

Show CREATE DATABASE database_name;
Explanation: Displays the SQL statement that creates the specified database

Show CREATE TABLE table_name;
Explanation: Displays the SQL statement that creates the specified data table

Show Engies;
Explanation: Displays the storage engine and default engine available after installation.

Show InnoDB status;
Explanation: Displays the status of the InnoDB storage engine

Show logs;
Explanation: Displays the log of the BDB storage engine

Show warnings;
Explanation: Displays errors, warnings, and notifications from the last executed statement

Show errors;
Explanation: Displays only the errors generated by the last execution statement

Most of the commands above can be used like '%abce% ', such as show table.

Report:

Show status Results Note

Column meaning
Name Table name
Types of type tables (Isam,myisam or heap)
Row_format row storage format (fixed, dynamic, or compressed)
Rows Row Quantity
Avg_row_length Average line length
Data_length the length of the data file
Maximum length of max_data_length data file
Index_length the length of the index file
Data_free has been allocated but no bytes have been used
Auto_increment Next AutoIncrement (auto plus 1) value
Create_time The time the table was created
Update_time when the data file was last updated
Check_time The last time a check is run on a table
Create_options additional options for use with CREATE table
Comment When creating tables, use annotations (or why MySQL cannot access some information about table information).
Show Index Results Note:

Column meaning
Table name
Non_unique 0 If the index cannot contain duplicates.
Key_name Index Name
The column order number in the Seq_in_index index, starting at 1.
COLUMN_NAME column name.
How the collation columns are sorted in the index. In MySQL, this can have value a (ascending) or null (not sorted).
The number of unique values in the cardinality index. This can be changed by running Isamchk-a.
Sub_part the number of indexed characters if the column is only partially indexed. NULL if the entire key is indexed.
Show variables Results:

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.
For some of the comments above:

If the opened_tables is too large, your table_cache variable may be too small.
If the key_reads is too big, then your key_cache may be too small. Cache hit rates can be computed using key_reads/key_read_requests.
If the handler_read_rnd is too large, then you are likely to have a large number of queries that require MySQL to scan the entire table or you have a join that does not use the key values correctly.

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.