《Mysql學習mysql show processlist 顯示mysql查詢進程》要點:
本文介紹了Mysql學習mysql show processlist 顯示mysql查詢進程,希望對您有用。如果有疑問,可以聯系我們。
MYSQL必讀SHOW PROCESSLIST顯示哪些線程正在運行.您也可以使用mysqladmin processlist語句得到此信息.如果您有SUPER權限,您可以看到所有線程.否則,您只能看到您自己的線程(也就是,與您正在使用的MySQL賬戶相關的線程).請參見13.5.5.3節,“KILL語法”.如果您不使用FULL關鍵詞,則只顯示每個查詢的前100個字符.
MYSQL必讀本語句報告TCP/IP連接的主機名稱(采用host_name:client_port格式),以方便地判定哪個客戶端正在做什么.
MYSQL必讀如果您得到“too many connections”錯誤信息,并且想要了解正在發生的情況,本語句是非常有用的.MySQL保留一個額外的連接,讓擁有SUPER權限的 賬戶使用,以確保管理員能夠隨時連接和檢查系統(假設您沒有把此權限給予所有的用戶).
MYSQL必讀這個命令中最關鍵的就是state列,mysql列出的狀態主要有以下幾種:
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已經處理完了所有待處理的插入操作,正在等待新的請求.
大部分狀態對應很快的操作,只要有一個線程保持同一個狀態好幾秒鐘,那么可能是有問題發生了,需要檢查一下.
還有其他的狀態沒在上面中列出來,不過它們大部分只是在查看服務器是否有存在錯誤是才用得著.
MYSQL必讀mysql 查看當前連接數
MYSQL必讀命令: show processlist;?
如果是root帳號,你能看到所有用戶的當前連接.如果是其它普通帳號,只能看到自己占用的連接.?
show processlist;只列出前100條,如果想全列出請使用show full processlist;?
mysql> show processlist;
MYSQL必讀命令: show status;
MYSQL必讀Aborted_clients 由于客戶沒有正確關閉連接已經死掉,已經放棄的連接數量.?
Aborted_connects 嘗試已經失敗的MySQL服務器的連接的次數.?
Connections 試圖連接MySQL服務器的次數.?
Created_tmp_tables 當執行語句時,已經被創造了的隱含臨時表的數量.?
Delayed_insert_threads 正在使用的延遲插入處理器線程的數量.?
Delayed_writes 用INSERT DELAYED寫入的行數.?
Delayed_errors 用INSERT DELAYED寫入的發生某些錯誤(可能重復鍵值)的行數.?
Flush_commands 執行FLUSH命令的次數.?
Handler_delete 請求從一張表中刪除行的次數.?
Handler_read_first 請求讀入表中第一行的次數.?
Handler_read_key 請求數字基于鍵讀行.?
Handler_read_next 請求讀入基于一個鍵的一行的次數.?
Handler_read_rnd 請求讀入基于一個固定位置的一行的次數.?
Handler_update 請求更新表中一行的次數.?
Handler_write 請求向表中插入一行的次數.?
Key_blocks_used 用于關鍵字緩存的塊的數量.?
Key_read_requests 請求從緩存讀入一個鍵值的次數.?
Key_reads 從磁盤物理讀入一個鍵值的次數.?
Key_write_requests 請求將一個關鍵字塊寫入緩存次數.?
Key_writes 將一個鍵值塊物理寫入磁盤的次數.?
Max_used_connections 同時使用的連接的最大數目.?
Not_flushed_key_blocks 在鍵緩存中已經改變但是還沒被清空到磁盤上的鍵塊.?
Not_flushed_delayed_rows 在INSERT DELAY隊列中等待寫入的行的數量.?
Open_tables 打開表的數量.?
Open_files 打開文件的數量.?
Open_streams 打開流的數量(主要用于日志記載)?
Opened_tables 已經打開的表的數量.?
Questions 發往服務器的查詢的數量.?
Slow_queries 要花超過long_query_time時間的查詢數量.?
Threads_connected 當前打開的連接的數量.?
Threads_running 不在睡眠的線程數量.?
Uptime 服務器工作了多少秒.
MYSQL必讀After create
MYSQL必讀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.
MYSQL必讀Analyzing
MYSQL必讀The thread is calculating a MyISAM table key distributions (for example, for ANALYZE TABLE).
MYSQL必讀checking permissions
MYSQL必讀The thread is checking whether the server has the required privileges to execute the statement.
MYSQL必讀Checking table
MYSQL必讀The thread is performing a table check operation.
MYSQL必讀cleaning up
MYSQL必讀The thread has processed one command and is preparing to free memory and reset certain state variables.
MYSQL必讀closing tables
MYSQL必讀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.
MYSQL必讀converting HEAP to MyISAM
MYSQL必讀The thread is converting an internal temporary table from a MEMORY table to an on-disk MyISAM table.
MYSQL必讀copy to tmp table
MYSQL必讀The thread is processing an ALTER TABLE statement. This state occurs after the table with the new structure has been created but before rows are copied into it.
MYSQL必讀Copying to group table
MYSQL必讀If a statement has different ORDER BY and GROUP BY criteria, the rows are sorted by group and copied to a temporary table.
MYSQL必讀Copying to tmp table
MYSQL必讀The server is copying to a temporary table in memory.
MYSQL必讀Copying to tmp table on disk
MYSQL必讀The server is copying to a temporary table on disk. The temporary result set was larger than tmp_table_size and the thread is changing the temporary table from in-memory to disk-based format to save memory.
MYSQL必讀Creating index
MYSQL必讀The thread is processing ALTER TABLE ... ENABLE KEYS for a MyISAM table.
MYSQL必讀Creating sort index
MYSQL必讀The thread is processing a SELECT that is resolved using an internal temporary table.
MYSQL必讀creating table
MYSQL必讀The thread is creating a table. This includes creation of temporary tables.
MYSQL必讀Creating tmp table
MYSQL必讀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 Copying to tmp table on disk.
MYSQL必讀deleting from main table
MYSQL必讀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.
MYSQL必讀deleting from reference tables
MYSQL必讀The server is executing the second part of a multiple-table delete and deleting the matched rows from the other tables.
MYSQL必讀discard_or_import_tablespace
MYSQL必讀The thread is processing an ALTER TABLE ... DISCARD TABLESPACE or ALTER TABLE ... IMPORT TABLESPACE statement.
MYSQL必讀end
MYSQL必讀This occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.
MYSQL必讀executing
MYSQL必讀The thread has begun executing a statement.
MYSQL必讀Execution of init_command
MYSQL必讀The thread is executing statements in the value of the init_command system variable.
MYSQL必讀freeing items
MYSQL必讀The thread has executed a command. This state is usually followed by cleaning up.
MYSQL必讀Flushing tables
MYSQL必讀The thread is executing FLUSH TABLES and is waiting for all threads to close their tables.
MYSQL必讀FULLTEXT initialization
MYSQL必讀The server is preparing to perform a natural-language full-text search.
MYSQL必讀init
MYSQL必讀This occurs before the initialization of ALTER TABLE, DELETE, INSERT, SELECT, or UPDATE statements.
MYSQL必讀Killed
MYSQL必讀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.
MYSQL必讀Locked
MYSQL必讀The query is locked by another query.
MYSQL必讀logging slow query
MYSQL必讀The thread is writing a statement to the slow-query log.
MYSQL必讀NULL
MYSQL必讀This state is used for the SHOW PROCESSLIST state.
MYSQL必讀login
MYSQL必讀The initial state for a connection thread until the client has been authenticated successfully.
MYSQL必讀Opening tables, Opening table
MYSQL必讀The thread is trying to open a table. This is should be very fast procedure, unless something prevents opening. For example, an ALTER TABLE or a LOCK TABLE statement can prevent opening a table until the statement is finished.
MYSQL必讀preparing
MYSQL必讀This state occurs during query optimization.
MYSQL必讀Purging old relay logs
MYSQL必讀The thread is removing unneeded relay log files.
MYSQL必讀query end
MYSQL必讀This state occurs after processing a query but before the freeing items state.
MYSQL必讀Reading from net
MYSQL必讀The server is reading a packet from the network.
MYSQL必讀Removing duplicates
MYSQL必讀The query was using 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.
MYSQL必讀removing tmp table
MYSQL必讀The thread is removing an internal temporary table after processing a SELECT statement. This state is not used if no temporary table was created.
MYSQL必讀rename
MYSQL必讀The thread is renaming a table.
MYSQL必讀rename result table
MYSQL必讀The thread is processing an ALTER TABLE statement, has created the new table, and is renaming it to replace the original table.
MYSQL必讀Reopen tables
MYSQL必讀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.
MYSQL必讀Repair by sorting
MYSQL必讀The repair code is using a sort to create indexes.
MYSQL必讀Repair done
MYSQL必讀The thread has completed a multi-threaded repair for a MyISAM table.
MYSQL必讀Repair with keycache
MYSQL必讀The repair code is using creating keys one by one through the key cache. This is much slower than Repair by sorting.
MYSQL必讀Rolling back
MYSQL必讀The thread is rolling back a transaction.
MYSQL必讀Saving state
MYSQL必讀For 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.
MYSQL必讀Searching rows for update
MYSQL必讀The thread is doing a first phase to find all matching rows before updating them. This has to be done if the UPDATE is changing the index that is used to find the involved rows.
MYSQL必讀Sending data
MYSQL必讀The thread is processing rows for a SELECT statement and also is sending data to the client.
MYSQL必讀setup
MYSQL必讀The thread is beginning an ALTER TABLE operation.
MYSQL必讀Sorting for group
MYSQL必讀The thread is doing a sort to satisfy a GROUP BY.
MYSQL必讀Sorting for order
MYSQL必讀The thread is doing a sort to satisfy a ORDER BY.
MYSQL必讀Sorting index
MYSQL必讀The thread is sorting index pages for more efficient access during a MyISAM table optimization operation.
MYSQL必讀Sorting result
MYSQL必讀For a SELECT statement, this is similar to Creating sort index, but for nontemporary tables.
MYSQL必讀statistics
MYSQL必讀The server is calculating statistics to develop a query execution plan.
MYSQL必讀System lock
MYSQL必讀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 --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).
MYSQL必讀Table lock
MYSQL必讀The next thread state after System lock. The thread has acquired an external lock and is going to request an internal table lock.
MYSQL必讀Updating
MYSQL必讀The thread is searching for rows to update and is updating them.
MYSQL必讀updating main table
MYSQL必讀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.
MYSQL必讀updating reference tables
MYSQL必讀The server is executing the second part of a multiple-table update and updating the matched rows from the other tables.
MYSQL必讀User lock
MYSQL必讀The thread is going to request or is waiting for an advisory lock requested with a GET_LOCK() call. For SHOW PROFILE, this state means the thread is requesting the lock (not waiting for it).
MYSQL必讀Waiting for tables, Waiting for table
MYSQL必讀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.
MYSQL必讀This notification takes place if another thread has used 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.
MYSQL必讀Waiting on cond
MYSQL必讀A generic state in which the thread is waiting for a condition to become true. No specific state information is available.
MYSQL必讀Writing to net
MYSQL必讀The server is writing a packet to the network.
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/2353.html