全部博文(2065)
分类: Mysql/postgreSQL
2010-08-11 08:38:21
这个命令中最关键的就是state列,mysql列出的状态主要有以下几种:
Checking table
正在检查数据表(这是自动的)。
Closing tables
正在将表中修改的数据刷新到磁盘中,同时正在关闭已经用完的表。这是一个很快的操作,如果不是这样的话,就应该确认磁盘空间是否已经满了或者磁盘是否正处于重负中。
Connect Out
复制从服务器正在连接主服务器。
Copying to tmp table on disk
由于临时结果集大于tmp_table_size,正在将临时表从内存存储转为磁盘存储以此节省内存。
Creating tmp table
正在创建临时表以存放部分查询结果。
deleting from main table
服务器正在执行多表删除中的第一部分,刚删除第一个表。
deleting from reference tables
服务器正在执行多表删除中的第二部分,正在删除表的记录。
Flushing tables
正在执行FLUSH TABLES,等待其他线程关闭数据表。
Killed
发送了一个kill请求给某线程,那么这个线程将会检查kill标志位,同时会放弃下一个kill请求。MySQL会在每次的主循环中检查kill标志位,不过有些情况下该线程可能会过一小段才能死掉。如果该线程程被其他线程锁住了,那么kill请求会在锁释放时马上生效。
Locked
被其他查询锁住了。
Sending data
正在处理SELECT查询的记录,同时正在把结果发送给客户端。
Sorting for group
正在为GROUP BY做排序。
Sorting for order
正在为ORDER BY做排序。
Opening tables
这个过程应该会很快,除非受到其他因素的干扰。例如,在执ALTER TABLE或LOCK TABLE语句行完以前,数据表无法被其他线程打开。正尝试打开一个表。
Removing duplicates
正在执行一个SELECT DISTINCT方式的查询,但是MySQL无法在前一个阶段优化掉那些重复的记录。因此,MySQL需要再次去掉重复的记录,然后再把结果发送给客户端。
Reopen table
获得了对一个表的锁,但是必须在表结构修改之后才能获得这个锁。已经释放锁,关闭数据表,正尝试重新打开数据表。
Repair by sorting
修复指令正在排序以创建索引。
Repair with keycache
修复指令正在利用索引缓存一个一个地创建新索引。它会比Repair by sorting慢些。
Searching rows for update
正在讲符合条件的记录找出来以备更新。它必须在UPDATE要修改相关的记录之前就完成了。
Sleeping
正在等待客户端发送新请求.
System lock
正在等待取得一个外部的系统锁。如果当前没有运行多个mysqld服务器同时请求同一个表,那么可以通过增加--skip-external-locking参数来禁止外部系统锁。
Upgrading lock
INSERT DELAYED正在尝试取得一个锁表以插入新记录。
Updating
正在搜索匹配的记录,并且修改它们。
User Lock
正在等待GET_LOCK()。
Waiting for tables
该线程得到通知,数据表结构已经被修改了,需要重新打开数据表以取得新的结构。然后,为了能的重新打开数据表,必须等到所有其他线程关闭这个表。以下几种情况下会产生这个通知:FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE,或OPTIMIZE TABLE。
waiting for handler insert
INSERT DELAYED已经处理完了所有待处理的插入操作,正在等待新的请求。
大部分状态对应很快的操作,只要有一个线程保持同一个状态好几秒钟,那么可能是有问题发生了,需要检查一下。
还有其他的状态没在上面中列出来,不过它们大部分只是在查看服务器是否有存在错误是才用得着。
This occurs when the thread creates a table (including internal
temporary tables), at the end of the function that creates the table.
This state is used even if the table could not be created due to some
error. The thread is calculating a The thread is checking whether the server has the required privileges to execute the statement. The thread is performing a table check operation. The thread has processed one command and is preparing to free memory and reset certain state variables. The thread is flushing the changed table data to disk and closing
the used tables. This should be a fast operation. If not, you should
verify that you do not have a full disk and that the disk is not in
very heavy use. The thread is converting an internal temporary table from a The thread is processing an If a statement has different The server is copying to a temporary table in memory. The server is copying to a temporary table on disk. The temporary result set was larger than The thread is processing The thread is processing a The thread is creating a table. This includes creation of temporary tables. The thread is creating a temporary table in memory or on disk. If
the table is created in memory but later is converted to an on-disk
table, the state during that operation will be The server is executing the first part of a multiple-table delete.
It is deleting only from the first table, and saving columns and
offsets to be used for deleting from the other (reference) tables. The server is executing the second part of a multiple-table delete and deleting the matched rows from the other tables. The thread is processing an This occurs at the end but before the cleanup of The thread has begun executing a statement. The thread is executing statements in the value of the The thread has executed a command. This state is usually followed by The thread is executing The server is preparing to perform a natural-language full-text search. This occurs before the initialization of Someone has sent a The query is locked by another query. The thread is writing a statement to the slow-query log. This state is used for the The initial state for a connection thread until the client has been authenticated successfully. The thread is trying to open a table. This is should be very fast procedure, unless something prevents opening. For example, an This state occurs during query optimization. The thread is removing unneeded relay log files. This state occurs after processing a query but before the The server is reading a packet from the network. The query was using The thread is removing an internal temporary table after processing a The thread is renaming a table. The thread is processing an The thread got a lock for the table, but noticed after getting the
lock that the underlying table structure changed. It has freed the
lock, closed the table, and is trying to reopen it. The repair code is using a sort to create indexes. The thread has completed a multi-threaded repair for a The repair code is using creating keys one by one through the key cache. This is much slower than The thread is rolling back a transaction. For The thread is doing a first phase to find all matching rows before updating them. This has to be done if the The thread is processing rows for a The thread is beginning an The thread is doing a sort to satisfy a The thread is doing a sort to satisfy a The thread is sorting index pages for more efficient access during a For a The server is calculating statistics to develop a query execution plan. The thread is going to request or is waiting for an internal or
external system lock for the table. If this state is being caused by
requests for external locks and you are not using multiple mysqld servers that are accessing the same tables, you can disable external system locks with the The next thread state after The thread is searching for rows to update and is updating them. The server is executing the first part of a multiple-table update.
It is updating only the first table, and saving columns and offsets to
be used for updating the other (reference) tables. The server is executing the second part of a multiple-table update and updating the matched rows from the other tables. The thread is going to request or is waiting for an advisory lock requested with a The thread got a notification that the underlying structure for a
table has changed and it needs to reopen the table to get 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 A generic state in which the thread is waiting for a condition to become true. No specific state information is available. The server is writing a packet to the network. After create
Analyzing
MyISAM
table key distributions (for example, for ANALYZE TABLE
). checking permissions
Checking table
cleaning up
closing tables
converting HEAP to MyISAM
MEMORY
table to an on-disk MyISAM
table. copy to tmp table
ALTER TABLE
statement. This state occurs after the table with the new structure has been created but before rows are copied into it. Copying to group table
ORDER BY
and GROUP BY
criteria, the rows are sorted by group and copied to a temporary table. Copying to tmp table
Copying to tmp table on disk
tmp_table_size
and the thread is changing the temporary table from in-memory to disk-based format to save memory. Creating index
ALTER TABLE ... ENABLE KEYS
for a MyISAM
table. Creating sort index
SELECT
that is resolved using an internal temporary table. creating table
Creating tmp table
Copying to tmp table on disk
. deleting from main table
deleting from reference tables
discard_or_import_tablespace
ALTER TABLE ... DISCARD TABLESPACE
or ALTER TABLE ... IMPORT TABLESPACE
statement. end
ALTER TABLE
, CREATE VIEW
, DELETE
, INSERT
, SELECT
, or UPDATE
statements. executing
Execution of init_command
init_command
system variable. freeing items
cleaning up
. Flushing tables
FLUSH TABLES
and is waiting for all threads to close their tables. FULLTEXT initialization
init
ALTER TABLE
, DELETE
, INSERT
, SELECT
, or UPDATE
statements. Killed
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
logging slow query
NULL
SHOW PROCESSLIST
state. login
Opening tables
, Opening table
ALTER TABLE
or a LOCK TABLE
statement can prevent opening a table until the statement is finished. preparing
Purging old relay logs
query end
freeing items
state. Reading from net
Removing duplicates
SELECT DISTINCT
in such a way that MySQL could not optimize away the distinct operation
at an early stage. Because of this, MySQL requires an extra stage to
remove all duplicated rows before sending the result to the client. removing tmp table
SELECT
statement. This state is not used if no temporary table was created. rename
rename result table
ALTER TABLE
statement, has created the new table, and is renaming it to replace the original table. Reopen tables
Repair by sorting
Repair done
MyISAM
table. Repair with keycache
Repair by sorting
. Rolling back
Saving state
MyISAM
table operations such as repair or analysis, the thread is 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
UPDATE
is changing the index that is used to find the involved rows. Sending data
SELECT
statement and also is sending data to the client. setup
ALTER TABLE
operation. Sorting for group
GROUP BY
. Sorting for order
ORDER BY
. Sorting index
MyISAM
table optimization operation. Sorting result
SELECT
statement, this is similar to Creating sort index
, but for nontemporary tables. statistics
System lock
--skip-external-locking
option. However, external locking is disabled by default, so it is likely that this option will have no effect. For SHOW PROFILE
, this state means the thread is requesting the lock (not waiting for it). Table lock
System lock
. The thread has acquired an external lock and is going to request an internal table lock. Updating
updating main table
updating reference tables
User lock
GET_LOCK()
call. For SHOW PROFILE
, this state means the thread is requesting the lock (not waiting for it). Waiting for tables
, Waiting for table
FLUSH TABLES
or one of the following statements on the table in question: FLUSH TABLES
, tbl_name
ALTER TABLE
, RENAME TABLE
, REPAIR TABLE
, ANALYZE TABLE
, or OPTIMIZE TABLE
. Waiting on cond
Writing to net