欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql show processlist 顯示mysql查詢進程

 更新時間:2012年03月01日 23:16:56   作者:  
processlist命令的輸出結(jié)果顯示了有哪些線程在運行,可以幫助識別出有問題的查詢語句,兩種方式使用這個命令
1.進入mysql/bin目錄下輸入mysqladmin processlist;
2.啟動mysql,輸入show processlist;
如果有 SUPER 權(quán)限,則可以看到全部的線程,否則,只能看到自己發(fā)起的線程(這是指,當前對應的MySQL帳戶運行的線程)。
得到數(shù)據(jù)形式如下(只截取了三條):
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
先簡單說一下各列的含義和用途,第一列,id,不用說了吧,一個標識,你要kill一個語句的時候很有用。user列,顯示單前用戶,如果不是root,這個命令就只顯示你權(quán)限范圍內(nèi)的sql語句。host列,顯示這個語句是從哪個ip的哪個端口上發(fā)出的。呵呵,可以用來追蹤出問題語句的用戶。db列,顯示這個進程目前連接的是哪個數(shù)據(jù)庫。command列,顯示當前連接的執(zhí)行的命令,一般就是休眠(sleep),查詢(query),連接(connect)。time列,此這個狀態(tài)持續(xù)的時間,單位是秒。state列,顯示使用當前連接的sql語句的狀態(tài),很重要的列,后續(xù)會有所有的狀態(tài)的描述,請注意,state只是語句執(zhí)行中的某一個狀態(tài),一個sql語句,已查詢?yōu)槔赡苄枰?jīng)過copying to tmp table,Sorting result,Sending data等狀態(tài)才可以完成,info列,顯示這個sql語句

如果你在一個容量大的表中執(zhí)行增刪改字段或執(zhí)行一個復雜的sql 查詢導致mysql線程掛起.可用此命令查看出是哪些sql掛起,用kill命令把他K掉

kill命令使用方法

kill pid

如上例中我們想kill掉id為207的線程則執(zhí)行

kill 207即可.

mysql show processlist命令 詳解


SHOW PROCESSLIST顯示哪些線程正在運行。您也可以使用mysqladmin processlist語句得到此信息。如果您有SUPER權(quán)限,您可以看到所有線程。否則,您只能看到您自己的線程(也就是,與您正在使用的MySQL賬戶相關(guān)的線程)。請參見13.5.5.3節(jié),“KILL語法”。如果您不使用FULL關(guān)鍵詞,則只顯示每個查詢的前100個字符。

本語句報告TCP/IP連接的主機名稱(采用host_name:client_port格式),以方便地判定哪個客戶端正在做什么。

如果您得到“too many connections”錯誤信息,并且想要了解正在發(fā)生的情況,本語句是非常有用的。MySQL保留一個額外的連接,讓擁有SUPER權(quán)限的 賬戶使用,以確保管理員能夠隨時連接和檢查系統(tǒng)(假設(shè)您沒有把此權(quán)限給予所有的用戶)。

這個命令中最關(guān)鍵的就是state列,mysql列出的狀態(tài)主要有以下幾種:

Checking table
 正在檢查數(shù)據(jù)表(這是自動的)。
Closing tables
 正在將表中修改的數(shù)據(jù)刷新到磁盤中,同時正在關(guān)閉已經(jīng)用完的表。這是一個很快的操作,如果不是這樣的話,就應該確認磁盤空間是否已經(jīng)滿了或者磁盤是否正處于重負中。
Connect Out
 復制從服務器正在連接主服務器。
Copying to tmp table on disk
 由于臨時結(jié)果集大于tmp_table_size,正在將臨時表從內(nèi)存存儲轉(zhuǎn)為磁盤存儲以此節(jié)省內(nèi)存。
Creating tmp table
 正在創(chuàng)建臨時表以存放部分查詢結(jié)果。
deleting from main table
 服務器正在執(zhí)行多表刪除中的第一部分,剛刪除第一個表。
deleting from reference tables
 服務器正在執(zhí)行多表刪除中的第二部分,正在刪除其他表的記錄。
Flushing tables
 正在執(zhí)行FLUSH TABLES,等待其他線程關(guān)閉數(shù)據(jù)表。
Killed
 發(fā)送了一個kill請求給某線程,那么這個線程將會檢查kill標志位,同時會放棄下一個kill請求。MySQL會在每次的主循環(huán)中檢查kill標志位,不過有些情況下該線程可能會過一小段才能死掉。如果該線程程被其他線程鎖住了,那么kill請求會在鎖釋放時馬上生效。
Locked
 被其他查詢鎖住了。
Sending data
 正在處理SELECT查詢的記錄,同時正在把結(jié)果發(fā)送給客戶端。
Sorting for group
 正在為GROUP BY做排序。
 Sorting for order
 正在為ORDER BY做排序。
Opening tables
 這個過程應該會很快,除非受到其他因素的干擾。例如,在執(zhí)ALTER TABLE或LOCK TABLE語句行完以前,數(shù)據(jù)表無法被其他線程打開。正嘗試打開一個表。
Removing duplicates
 正在執(zhí)行一個SELECT DISTINCT方式的查詢,但是MySQL無法在前一個階段優(yōu)化掉那些重復的記錄。因此,MySQL需要再次去掉重復的記錄,然后再把結(jié)果發(fā)送給客戶端。
Reopen table
 獲得了對一個表的鎖,但是必須在表結(jié)構(gòu)修改之后才能獲得這個鎖。已經(jīng)釋放鎖,關(guān)閉數(shù)據(jù)表,正嘗試重新打開數(shù)據(jù)表。
Repair by sorting
 修復指令正在排序以創(chuàng)建索引。
Repair with keycache
 修復指令正在利用索引緩存一個一個地創(chuàng)建新索引。它會比Repair by sorting慢些。
Searching rows for update
 正在講符合條件的記錄找出來以備更新。它必須在UPDATE要修改相關(guān)的記錄之前就完成了。
Sleeping
 正在等待客戶端發(fā)送新請求.
System lock
 正在等待取得一個外部的系統(tǒng)鎖。如果當前沒有運行多個mysqld服務器同時請求同一個表,那么可以通過增加--skip-external-locking參數(shù)來禁止外部系統(tǒng)鎖。
Upgrading lock
 INSERT DELAYED正在嘗試取得一個鎖表以插入新記錄。
Updating
 正在搜索匹配的記錄,并且修改它們。
User Lock
 正在等待GET_LOCK()。
Waiting for tables
 該線程得到通知,數(shù)據(jù)表結(jié)構(gòu)已經(jīng)被修改了,需要重新打開數(shù)據(jù)表以取得新的結(jié)構(gòu)。然后,為了能的重新打開數(shù)據(jù)表,必須等到所有其他線程關(guān)閉這個表。以下幾種情況下會產(chǎn)生這個通知:FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE,或OPTIMIZE TABLE。
waiting for handler insert
 INSERT DELAYED已經(jīng)處理完了所有待處理的插入操作,正在等待新的請求。
 大部分狀態(tài)對應很快的操作,只要有一個線程保持同一個狀態(tài)好幾秒鐘,那么可能是有問題發(fā)生了,需要檢查一下。
 還有其他的狀態(tài)沒在上面中列出來,不過它們大部分只是在查看服務器是否有存在錯誤是才用得著。

mysql 查看當前連接數(shù)

命令: show processlist; 
如果是root帳號,你能看到所有用戶的當前連接。如果是其它普通帳號,只能看到自己占用的連接。 
show processlist;只列出前100條,如果想全列出請使用show full processlist; 
mysql> show processlist;

命令: show status;

Aborted_clients 由于客戶沒有正確關(guān)閉連接已經(jīng)死掉,已經(jīng)放棄的連接數(shù)量。 
Aborted_connects 嘗試已經(jīng)失敗的MySQL服務器的連接的次數(shù)。 
Connections 試圖連接MySQL服務器的次數(shù)。 
Created_tmp_tables 當執(zhí)行語句時,已經(jīng)被創(chuàng)造了的隱含臨時表的數(shù)量。 
Delayed_insert_threads 正在使用的延遲插入處理器線程的數(shù)量。 
Delayed_writes 用INSERT DELAYED寫入的行數(shù)。 
Delayed_errors 用INSERT DELAYED寫入的發(fā)生某些錯誤(可能重復鍵值)的行數(shù)。 
Flush_commands 執(zhí)行FLUSH命令的次數(shù)。 
Handler_delete 請求從一張表中刪除行的次數(shù)。 
Handler_read_first 請求讀入表中第一行的次數(shù)。 
Handler_read_key 請求數(shù)字基于鍵讀行。 
Handler_read_next 請求讀入基于一個鍵的一行的次數(shù)。 
Handler_read_rnd 請求讀入基于一個固定位置的一行的次數(shù)。 
Handler_update 請求更新表中一行的次數(shù)。 
Handler_write 請求向表中插入一行的次數(shù)。 
Key_blocks_used 用于關(guān)鍵字緩存的塊的數(shù)量。 
Key_read_requests 請求從緩存讀入一個鍵值的次數(shù)。 
Key_reads 從磁盤物理讀入一個鍵值的次數(shù)。 
Key_write_requests 請求將一個關(guān)鍵字塊寫入緩存次數(shù)。 
Key_writes 將一個鍵值塊物理寫入磁盤的次數(shù)。 
Max_used_connections 同時使用的連接的最大數(shù)目。 
Not_flushed_key_blocks 在鍵緩存中已經(jīng)改變但是還沒被清空到磁盤上的鍵塊。 
Not_flushed_delayed_rows 在INSERT DELAY隊列中等待寫入的行的數(shù)量。 
Open_tables 打開表的數(shù)量。 
Open_files 打開文件的數(shù)量。 
Open_streams 打開流的數(shù)量(主要用于日志記載) 
Opened_tables 已經(jīng)打開的表的數(shù)量。 
Questions 發(fā)往服務器的查詢的數(shù)量。 
Slow_queries 要花超過long_query_time時間的查詢數(shù)量。 
Threads_connected 當前打開的連接的數(shù)量。 
Threads_running 不在睡眠的線程數(shù)量。 
Uptime 服務器工作了多少秒。

After create

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.

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 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.

converting HEAP to MyISAM

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

copy to tmp table

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.

Copying to group table

If a statement has different ORDER BY and GROUP BY criteria, the rows are sorted by 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 is changing the temporary table from in-memory to disk-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 that is resolved using an 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 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.

deleting from main table

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.

deleting from reference tables

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

discard_or_import_tablespace

The thread is processing an ALTER TABLE ... DISCARD TABLESPACE or ALTER TABLE ... IMPORT TABLESPACE statement.

end

This 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 state is usually followed by cleaning up.

Flushing tables

The thread is executing FLUSH TABLES and is 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 state is used for the SHOW PROCESSLIST state.

login

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

Opening tables, Opening table

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.

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 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.

removing tmp table

The thread is removing an internal temporary table after processing a SELECT statement. This state is not used if no temporary table was created.

rename

The thread is renaming a table.

rename result table

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

Reopen tables

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.

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 much 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 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

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.

Sending data

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

setup

The thread is beginning an 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 a 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, this 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 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).

Table lock

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

Updating

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

updating main table

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.

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 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).

Waiting for tables, Waiting for table

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 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

A generic state in which the thread is 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.

相關(guān)文章

  • MySQL安裝詳解圖文版(V5.5 For Windows)

    MySQL安裝詳解圖文版(V5.5 For Windows)

    這幾年一直在用MySQL,并且是Windows+.Net+MySQL的搭配,用MyISAM引擎支持過單表每天千萬以上的數(shù)據(jù)遞增,TB級的數(shù)據(jù)MySQL游刃有余。
    2011-09-09
  • 詳解Mysql查詢條件中字符串尾部有空格也能匹配上的問題

    詳解Mysql查詢條件中字符串尾部有空格也能匹配上的問題

    在本篇文章里小編給大家整理的是關(guān)于詳解Mysql查詢條件中字符串尾部有空格也能匹配上的問題,需要的朋友們可以參考下
    2020-02-02
  • MYSQL中Truncate的用法詳解

    MYSQL中Truncate的用法詳解

    這篇文章主要介紹了MYSQL中Truncate的用法詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-01-01
  • Mysql數(shù)據(jù)庫之索引優(yōu)化

    Mysql數(shù)據(jù)庫之索引優(yōu)化

    MySQL憑借著出色的性能、低廉的成本、豐富的資源,已經(jīng)成為絕大多數(shù)互聯(lián)網(wǎng)公司的首選關(guān)系型數(shù)據(jù)庫。本文給大家介紹mysql數(shù)據(jù)庫之索引優(yōu)化,感興趣的朋友一起學習吧
    2016-03-03
  • mysql字段截取的幾種函數(shù)和搭配函數(shù)示例代碼

    mysql字段截取的幾種函數(shù)和搭配函數(shù)示例代碼

    在 MySQL 數(shù)據(jù)庫中,有時我們需要截取字段或字符串的一部分進行查詢、展示或處理,下面這篇文章主要介紹了mysql字段截取的幾種函數(shù)和搭配函數(shù)的相關(guān)資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2025-09-09
  • 詳解如何使用DockerHub官方的MySQL鏡像

    詳解如何使用DockerHub官方的MySQL鏡像

    MySQL是一個廣泛使用的開源關(guān)系型數(shù)據(jù)庫,那如何獲取Mysql Docker鏡像?下面通過這篇文章來一起看看如何使用DockerHub官方的MySQL鏡像,有需要的朋友們可以參考借鑒。
    2016-12-12
  • MySQL分表自動化創(chuàng)建的實現(xiàn)方案

    MySQL分表自動化創(chuàng)建的實現(xiàn)方案

    在數(shù)據(jù)庫應用場景中,隨著數(shù)據(jù)量的不斷增長,單表存儲數(shù)據(jù)可能會面臨性能瓶頸,例如查詢、插入、更新等操作的效率會逐漸降低,分表是一種有效的優(yōu)化策略,它將數(shù)據(jù)分散存儲在多個表中,從而提高數(shù)據(jù)庫的性能和可維護性,本文介紹了MySQL分表自動化創(chuàng)建的實現(xiàn)方案
    2025-01-01
  • MySQL 語句執(zhí)行順序舉例解析

    MySQL 語句執(zhí)行順序舉例解析

    這篇文章主要介紹了MySQL 語句執(zhí)行順序舉例解析,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值需要的小伙伴可以參考一下
    2022-06-06
  • MySQL基礎(chǔ)教程之事務異常情況

    MySQL基礎(chǔ)教程之事務異常情況

    事務(Transaction)是訪問和更新數(shù)據(jù)庫的程序執(zhí)行單元;事務中可能包含一個或多個sql語句,這些語句要么都執(zhí)行,要么都不執(zhí)行,下面這篇文章主要給大家介紹了關(guān)于MySQL基礎(chǔ)教程之事務異常情況的相關(guān)資料,需要的朋友可以參考下
    2022-10-10
  • mysql 索引分類以及用途分析

    mysql 索引分類以及用途分析

    MySQL索引分為普通索引、唯一性索引、全文索引、單列索引、多列索引等等。這里將為大家介紹著幾種索引各自的用途。
    2011-08-08

最新評論