{"id":885,"date":"2015-08-09T17:58:10","date_gmt":"2015-08-09T09:58:10","guid":{"rendered":"http:\/\/www.royalwzy.com\/?p=885"},"modified":"2015-09-10T21:53:01","modified_gmt":"2015-09-10T13:53:01","slug":"mysql-show-processlist","status":"publish","type":"post","link":"http:\/\/www.royalwzy.com\/?p=885","title":{"rendered":"SHOW PROCESSLIST\u4ecb\u7ecd\u548c\u4f7f\u7528"},"content":{"rendered":"<p>processlist\u547d\u4ee4\u7684\u8f93\u51fa\u7ed3\u679c\u663e\u793a\u4e86\u6709\u54ea\u4e9b\u7ebf\u7a0b\u5728\u8fd0\u884c\uff0c\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u51fa\u6709\u95ee\u9898\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u4e24\u79cd\u65b9\u5f0f\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u3002<br \/>\n1.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fdb\u5165mysql\/bin\u76ee\u5f55\u4e0b\u8f93\u5165mysqladmin processlist;<br \/>\n2.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u542f\u52a8mysql\uff0c\u8f93\u5165show processlist;<br \/>\n\u5982\u679c\u6709SUPER\u6743\u9650\uff0c\u5219\u53ef\u4ee5\u770b\u5230\u5168\u90e8\u7684\u7ebf\u7a0b\uff0c\u5426\u5219\uff0c\u53ea\u80fd\u770b\u5230\u81ea\u5df1\u53d1\u8d77\u7684\u7ebf\u7a0b\uff08\u8fd9\u662f\u6307\uff0c\u5f53\u524d\u5bf9\u5e94\u7684MySQL\u5e10\u6237\u8fd0\u884c\u7684\u7ebf\u7a0b\uff09\u3002<\/p>\n<p>mysql&gt; show processlist<\/p>\n<p>-&gt; ;<\/p>\n<p>+&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n<p>| Id | User\u00a0 | Host \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | db \u00a0 | Command | Time | State | Info \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<\/p>\n<p>+&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n<p>| 34 | ucjmh | 192.168.56.101:54031 | NULL | Query \u00a0 |\u00a0 \u00a0 0 | NULL\u00a0 | show processlist |<\/p>\n<p>+&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>mysql&gt; exit<\/p>\n<p>Bye<\/p>\n<p>[root@ucjmh ~]# mysql -uroot -poracle<\/p>\n<p>Welcome to the MySQL monitor.\u00a0 Commands end with ; or \\g.<\/p>\n<p>Your MySQL connection id is 35<\/p>\n<p>Server version: 5.5.41-log Source distribution<\/p>\n<p>Copyright (c) 2000, 2014, Oracle and\/or its affiliates. All rights reserved.<\/p>\n<p>Oracle is a registered trademark of Oracle Corporation and\/or its<\/p>\n<p>affiliates. Other names may be trademarks of their respective<\/p>\n<p>owners.<\/p>\n<p>Type &#8216;help;&#8217; or &#8216;\\h&#8217; for help. Type &#8216;\\c&#8217; to clear the current input statement.<\/p>\n<p>mysql&gt; show processlist;<\/p>\n<p>+&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n<p>| Id | User | Host\u00a0 \u00a0 \u00a0 | db \u00a0 | Command | Time | State | Info \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<\/p>\n<p>+&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n<p>| 35 | root | localhost | NULL | Query \u00a0 |\u00a0 \u00a0 0 | NULL\u00a0 | show processlist |<\/p>\n<p>+&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>\u5404\u5217\u7684\u542b\u4e49\u548c\u7528\u9014:<\/p>\n<p>id\uff0c\u6807\u8bc6\u4f1a\u8bddid \u7c7b\u4f3c\u4e8eoracle\u4e2d\u7684sid\uff0c\u4f60\u8981kill\u4e00\u4e2a\u8bed\u53e5\u7684\u65f6\u5019\u5f88\u6709\u7528\u3002<\/p>\n<p>user\u5217\uff0c\u663e\u793a\u5355\u524d\u7528\u6237\uff0c\u5982\u679c\u4e0d\u662froot\uff0c\u8fd9\u4e2a\u547d\u4ee4\u5c31\u53ea\u663e\u793a\u4f60\u6743\u9650\u8303\u56f4\u5185\u7684sql\u8bed\u53e5\u3002<\/p>\n<p>host\u5217\uff0c\u663e\u793a\u8fd9\u4e2a\u8bed\u53e5\u662f\u4ece\u54ea\u4e2aip\u7684\u54ea\u4e2a\u7aef\u53e3\u4e0a\u53d1\u51fa\u7684\u3002\u7528\u6765\u8ffd\u8e2a\u51fa\u95ee\u9898\u8bed\u53e5\u7684\u7528\u6237\u3002<\/p>\n<p>db\u5217\uff0c\u663e\u793a\u8fd9\u4e2a\u8fdb\u7a0b\u76ee\u524d\u8fde\u63a5\u7684\u662f\u54ea\u4e2a\u6570\u636e\u5e93\u3002<\/p>\n<p>command\u5217\uff0c\u663e\u793a\u5f53\u524d\u8fde\u63a5\u7684\u6267\u884c\u7684\u547d\u4ee4\uff0c\u4e00\u822c\u5c31\u662f\u4f11\u7720\uff08sleep\uff09\uff0c\u67e5\u8be2\uff08query\uff09\uff0c\u8fde\u63a5\uff08connect\uff09\u3002<\/p>\n<p>time\u5217\uff0c\u6b64\u8fd9\u4e2a\u72b6\u6001\u6301\u7eed\u7684\u65f6\u95f4\uff0c\u5355\u4f4d\u662f\u79d2\u3002<\/p>\n<p>state\u5217\uff0c\u663e\u793a\u4f7f\u7528\u5f53\u524d\u8fde\u63a5\u7684sql\u8bed\u53e5\u7684\u72b6\u6001\uff0c\u5f88\u91cd\u8981\u7684\u5217\uff0c\u540e\u7eed\u4f1a\u6709\u6240\u6709\u7684\u72b6\u6001\u7684\u63cf\u8ff0\uff0c\u8bf7\u6ce8\u610f\uff0cstate\u53ea\u662f\u8bed\u53e5\u6267\u884c\u4e2d\u7684\u67d0\u4e00\u4e2a\u72b6\u6001\uff0c\u4e00\u4e2asql\u8bed\u53e5\uff0c\u5df2\u67e5\u8be2\u4e3a\u4f8b\uff0c\u53ef\u80fd\u9700\u8981\u7ecf\u8fc7copying to tmp table\uff0cSorting result\uff0cSending data\u7b49\u72b6\u6001\u624d\u53ef\u4ee5\u5b8c\u6210\uff0c<\/p>\n<p>info\u5217\uff0c\u663e\u793a\u8fd9\u4e2asql\u8bed\u53e5\uff0c\u56e0\u4e3a\u957f\u5ea6\u6709\u9650\uff0c\u6240\u4ee5\u957f\u7684sql\u8bed\u53e5\u5c31\u663e\u793a\u4e0d\u5168\uff0c\u4f46\u662f\u4e00\u4e2a\u5224\u65ad\u95ee\u9898\u8bed\u53e5\u7684\u91cd\u8981\u4f9d\u636e\u3002Checking table<br \/>\n\u6b63\u5728\u68c0\u67e5\u6570\u636e\u8868\uff08\u8fd9\u662f\u81ea\u52a8\u7684\uff09\u3002<br \/>\nClosing tables<br \/>\n\u6b63\u5728\u5c06\u8868\u4e2d\u4fee\u6539\u7684\u6570\u636e\u5237\u65b0\u5230\u78c1\u76d8\u4e2d\uff0c\u540c\u65f6\u6b63\u5728\u5173\u95ed\u5df2\u7ecf\u7528\u5b8c\u7684\u8868\u3002\u8fd9\u662f\u4e00\u4e2a\u5f88\u5feb\u7684\u64cd\u4f5c\uff0c\u5982\u679c\u4e0d\u662f\u8fd9\u6837\u7684\u8bdd\uff0c\u5c31\u5e94\u8be5\u786e\u8ba4\u78c1\u76d8\u7a7a\u95f4\u662f\u5426\u5df2\u7ecf\u6ee1\u4e86\u6216\u8005\u78c1\u76d8\u662f\u5426\u6b63\u5904\u4e8e\u91cd\u8d1f\u4e2d\u3002<br \/>\nConnect Out<br \/>\n\u590d\u5236\u4ece\u670d\u52a1\u5668\u6b63\u5728\u8fde\u63a5\u4e3b\u670d\u52a1\u5668\u3002<br \/>\nCopying to tmp table on disk<br \/>\n\u7531\u4e8e\u4e34\u65f6\u7ed3\u679c\u96c6\u5927\u4e8etmp_table_size\uff0c\u6b63\u5728\u5c06\u4e34\u65f6\u8868\u4ece\u5185\u5b58\u5b58\u50a8\u8f6c\u4e3a\u78c1\u76d8\u5b58\u50a8\u4ee5\u6b64\u8282\u7701\u5185\u5b58\u3002<br \/>\nCreating tmp table<br \/>\n\u6b63\u5728\u521b\u5efa\u4e34\u65f6\u8868\u4ee5\u5b58\u653e\u90e8\u5206\u67e5\u8be2\u7ed3\u679c\u3002<br \/>\ndeleting from main table<br \/>\n\u670d\u52a1\u5668\u6b63\u5728\u6267\u884c\u591a\u8868\u5220\u9664\u4e2d\u7684\u7b2c\u4e00\u90e8\u5206\uff0c\u521a\u5220\u9664\u7b2c\u4e00\u4e2a\u8868\u3002<br \/>\ndeleting from reference tables<br \/>\n\u670d\u52a1\u5668\u6b63\u5728\u6267\u884c\u591a\u8868\u5220\u9664\u4e2d\u7684\u7b2c\u4e8c\u90e8\u5206\uff0c\u6b63\u5728\u5220\u9664\u5176\u4ed6\u8868\u7684\u8bb0\u5f55\u3002<br \/>\nFlushing tables<br \/>\n\u6b63\u5728\u6267\u884cFLUSH TABLES\uff0c\u7b49\u5f85\u5176\u4ed6\u7ebf\u7a0b\u5173\u95ed\u6570\u636e\u8868\u3002<br \/>\nKilled<br \/>\n\u53d1\u9001\u4e86\u4e00\u4e2akill\u8bf7\u6c42\u7ed9\u67d0\u7ebf\u7a0b\uff0c\u90a3\u4e48\u8fd9\u4e2a\u7ebf\u7a0b\u5c06\u4f1a\u68c0\u67e5kill\u6807\u5fd7\u4f4d\uff0c\u540c\u65f6\u4f1a\u653e\u5f03\u4e0b\u4e00\u4e2akill\u8bf7\u6c42\u3002MySQL\u4f1a\u5728\u6bcf\u6b21\u7684\u4e3b\u5faa\u73af\u4e2d\u68c0\u67e5kill\u6807\u5fd7\u4f4d\uff0c\u4e0d\u8fc7\u6709\u4e9b\u60c5\u51b5\u4e0b\u8be5\u7ebf\u7a0b\u53ef\u80fd\u4f1a\u8fc7\u4e00\u5c0f\u6bb5\u624d\u80fd\u6b7b\u6389\u3002\u5982\u679c\u8be5\u7ebf\u7a0b\u7a0b\u88ab\u5176\u4ed6\u7ebf\u7a0b\u9501\u4f4f\u4e86\uff0c\u90a3\u4e48kill\u8bf7\u6c42\u4f1a\u5728\u9501\u91ca\u653e\u65f6\u9a6c\u4e0a\u751f\u6548\u3002<br \/>\nLocked<br \/>\n\u88ab\u5176\u4ed6\u67e5\u8be2\u9501\u4f4f\u4e86\u3002<br \/>\nSending data<br \/>\n\u6b63\u5728\u5904\u7406Select\u67e5\u8be2\u7684\u8bb0\u5f55\uff0c\u540c\u65f6\u6b63\u5728\u628a\u7ed3\u679c\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u3002<br \/>\nSorting for group<br \/>\n\u6b63\u5728\u4e3aGROUP BY\u505a\u6392\u5e8f\u3002<br \/>\nSorting for order<br \/>\n\u6b63\u5728\u4e3aORDER BY\u505a\u6392\u5e8f\u3002<br \/>\nOpening tables<br \/>\n\u8fd9\u4e2a\u8fc7\u7a0b\u5e94\u8be5\u4f1a\u5f88\u5feb\uff0c\u9664\u975e\u53d7\u5230\u5176\u4ed6\u56e0\u7d20\u7684\u5e72\u6270\u3002\u4f8b\u5982\uff0c\u5728\u6267Alter TABLE\u6216LOCK TABLE\u8bed\u53e5\u884c\u5b8c\u4ee5\u524d\uff0c\u6570\u636e\u8868\u65e0\u6cd5\u88ab\u5176\u4ed6\u7ebf\u7a0b\u6253\u5f00\u3002\u6b63\u5c1d\u8bd5\u6253\u5f00\u4e00\u4e2a\u8868\u3002<br \/>\nRemoving duplicates<br \/>\n\u6b63\u5728\u6267\u884c\u4e00\u4e2aSelect DISTINCT\u65b9\u5f0f\u7684\u67e5\u8be2\uff0c\u4f46\u662fMySQL\u65e0\u6cd5\u5728\u524d\u4e00\u4e2a\u9636\u6bb5\u4f18\u5316\u6389\u90a3\u4e9b\u91cd\u590d\u7684\u8bb0\u5f55\u3002\u56e0\u6b64\uff0cMySQL\u9700\u8981\u518d\u6b21\u53bb\u6389\u91cd\u590d\u7684\u8bb0\u5f55\uff0c\u7136\u540e\u518d\u628a\u7ed3\u679c\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u3002<br \/>\nReopen table<br \/>\n\u83b7\u5f97\u4e86\u5bf9\u4e00\u4e2a\u8868\u7684\u9501\uff0c\u4f46\u662f\u5fc5\u987b\u5728\u8868\u7ed3\u6784\u4fee\u6539\u4e4b\u540e\u624d\u80fd\u83b7\u5f97\u8fd9\u4e2a\u9501\u3002\u5df2\u7ecf\u91ca\u653e\u9501\uff0c\u5173\u95ed\u6570\u636e\u8868\uff0c\u6b63\u5c1d\u8bd5\u91cd\u65b0\u6253\u5f00\u6570\u636e\u8868\u3002<br \/>\nRepair by sorting<br \/>\n\u4fee\u590d\u6307\u4ee4\u6b63\u5728\u6392\u5e8f\u4ee5\u521b\u5efa\u7d22\u5f15\u3002<br \/>\nRepair with keycache<br \/>\n\u4fee\u590d\u6307\u4ee4\u6b63\u5728\u5229\u7528\u7d22\u5f15\u7f13\u5b58\u4e00\u4e2a\u4e00\u4e2a\u5730\u521b\u5efa\u65b0\u7d22\u5f15\u3002\u5b83\u4f1a\u6bd4Repair by sorting\u6162\u4e9b\u3002<br \/>\nSearching rows for update<br \/>\n\u6b63\u5728\u8bb2\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\u627e\u51fa\u6765\u4ee5\u5907\u66f4\u65b0\u3002\u5b83\u5fc5\u987b\u5728Update\u8981\u4fee\u6539\u76f8\u5173\u7684\u8bb0\u5f55\u4e4b\u524d\u5c31\u5b8c\u6210\u4e86\u3002<br \/>\nSleeping<br \/>\n\u6b63\u5728\u7b49\u5f85\u5ba2\u6237\u7aef\u53d1\u9001\u65b0\u8bf7\u6c42.<br \/>\nSystem lock<br \/>\n\u6b63\u5728\u7b49\u5f85\u53d6\u5f97\u4e00\u4e2a\u5916\u90e8\u7684\u7cfb\u7edf\u9501\u3002\u5982\u679c\u5f53\u524d\u6ca1\u6709\u8fd0\u884c\u591a\u4e2amysqld\u670d\u52a1\u5668\u540c\u65f6\u8bf7\u6c42\u540c\u4e00\u4e2a\u8868\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0&#8211;skip-external-locking\u53c2\u6570\u6765\u7981\u6b62\u5916\u90e8\u7cfb\u7edf\u9501\u3002<br \/>\nUpgrading lock<br \/>\nInsert DELAYED\u6b63\u5728\u5c1d\u8bd5\u53d6\u5f97\u4e00\u4e2a\u9501\u8868\u4ee5\u63d2\u5165\u65b0\u8bb0\u5f55\u3002<br \/>\nUpdating<br \/>\n\u6b63\u5728\u641c\u7d22\u5339\u914d\u7684\u8bb0\u5f55\uff0c\u5e76\u4e14\u4fee\u6539\u5b83\u4eec\u3002<br \/>\nUser Lock<br \/>\n\u6b63\u5728\u7b49\u5f85GET_LOCK()\u3002<br \/>\nWaiting for tables<br \/>\n\u8be5\u7ebf\u7a0b\u5f97\u5230\u901a\u77e5\uff0c\u6570\u636e\u8868\u7ed3\u6784\u5df2\u7ecf\u88ab\u4fee\u6539\u4e86\uff0c\u9700\u8981\u91cd\u65b0\u6253\u5f00\u6570\u636e\u8868\u4ee5\u53d6\u5f97\u65b0\u7684\u7ed3\u6784\u3002\u7136\u540e\uff0c\u4e3a\u4e86\u80fd\u7684\u91cd\u65b0\u6253\u5f00\u6570\u636e\u8868\uff0c\u5fc5\u987b\u7b49\u5230\u6240\u6709\u5176\u4ed6\u7ebf\u7a0b\u5173\u95ed\u8fd9\u4e2a\u8868\u3002\u4ee5\u4e0b\u51e0\u79cd\u60c5\u51b5\u4e0b\u4f1a\u4ea7\u751f\u8fd9\u4e2a\u901a\u77e5\uff1aFLUSH TABLES tbl_name, Alter TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE,\u6216OPTIMIZE TABLE\u3002<br \/>\nwaiting for handler insert<br \/>\nInsert DELAYED\u5df2\u7ecf\u5904\u7406\u5b8c\u4e86\u6240\u6709\u5f85\u5904\u7406\u7684\u63d2\u5165\u64cd\u4f5c\uff0c\u6b63\u5728\u7b49\u5f85\u65b0\u7684\u8bf7\u6c42\u3002<br \/>\n\u5927\u90e8\u5206\u72b6\u6001\u5bf9\u5e94\u5f88\u5feb\u7684\u64cd\u4f5c\uff0c\u53ea\u8981\u6709\u4e00\u4e2a\u7ebf\u7a0b\u4fdd\u6301\u540c\u4e00\u4e2a\u72b6\u6001\u597d\u51e0\u79d2\u949f\uff0c\u90a3\u4e48\u53ef\u80fd\u662f\u6709\u95ee\u9898\u53d1\u751f\u4e86\uff0c\u9700\u8981\u68c0\u67e5\u4e00\u4e0b\u3002<br \/>\n\u8fd9\u4e2a\u547d\u4ee4\u4e2d\u6700\u5173\u952e\u7684\u5c31\u662fstate\u5217\uff0cmysql\u5217\u51fa\u7684\u72b6\u6001\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n<p>Checking table<br \/>\n\u6b63\u5728\u68c0\u67e5\u6570\u636e\u8868\uff08\u8fd9\u662f\u81ea\u52a8\u7684\uff09\u3002<br \/>\nClosing tables<br \/>\n\u6b63\u5728\u5c06\u8868\u4e2d\u4fee\u6539\u7684\u6570\u636e\u5237\u65b0\u5230\u78c1\u76d8\u4e2d\uff0c\u540c\u65f6\u6b63\u5728\u5173\u95ed\u5df2\u7ecf\u7528\u5b8c\u7684\u8868\u3002\u8fd9\u662f\u4e00\u4e2a\u5f88\u5feb\u7684\u64cd\u4f5c\uff0c\u5982\u679c\u4e0d\u662f\u8fd9\u6837\u7684\u8bdd\uff0c\u5c31\u5e94\u8be5\u786e\u8ba4\u78c1\u76d8\u7a7a\u95f4\u662f\u5426\u5df2\u7ecf\u6ee1\u4e86\u6216\u8005\u78c1\u76d8\u662f\u5426\u6b63\u5904\u4e8e\u91cd\u8d1f\u4e2d\u3002<br \/>\nConnect Out<br \/>\n\u590d\u5236\u4ece\u670d\u52a1\u5668\u6b63\u5728\u8fde\u63a5\u4e3b\u670d\u52a1\u5668\u3002<br \/>\nCopying to tmp table on disk<br \/>\n\u7531\u4e8e\u4e34\u65f6\u7ed3\u679c\u96c6\u5927\u4e8etmp_table_size\uff0c\u6b63\u5728\u5c06\u4e34\u65f6\u8868\u4ece\u5185\u5b58\u5b58\u50a8\u8f6c\u4e3a\u78c1\u76d8\u5b58\u50a8\u4ee5\u6b64\u8282\u7701\u5185\u5b58\u3002<br \/>\nCreating tmp table<br \/>\n\u6b63\u5728\u521b\u5efa\u4e34\u65f6\u8868\u4ee5\u5b58\u653e\u90e8\u5206\u67e5\u8be2\u7ed3\u679c\u3002<br \/>\ndeleting from main table<br \/>\n\u670d\u52a1\u5668\u6b63\u5728\u6267\u884c\u591a\u8868\u5220\u9664\u4e2d\u7684\u7b2c\u4e00\u90e8\u5206\uff0c\u521a\u5220\u9664\u7b2c\u4e00\u4e2a\u8868\u3002<br \/>\ndeleting from reference tables<br \/>\n\u670d\u52a1\u5668\u6b63\u5728\u6267\u884c\u591a\u8868\u5220\u9664\u4e2d\u7684\u7b2c\u4e8c\u90e8\u5206\uff0c\u6b63\u5728\u5220\u9664\u5176\u4ed6\u8868\u7684\u8bb0\u5f55\u3002<br \/>\nFlushing tables<br \/>\n\u6b63\u5728\u6267\u884cFLUSH TABLES\uff0c\u7b49\u5f85\u5176\u4ed6\u7ebf\u7a0b\u5173\u95ed\u6570\u636e\u8868\u3002<br \/>\nKilled<br \/>\n\u53d1\u9001\u4e86\u4e00\u4e2akill\u8bf7\u6c42\u7ed9\u67d0\u7ebf\u7a0b\uff0c\u90a3\u4e48\u8fd9\u4e2a\u7ebf\u7a0b\u5c06\u4f1a\u68c0\u67e5kill\u6807\u5fd7\u4f4d\uff0c\u540c\u65f6\u4f1a\u653e\u5f03\u4e0b\u4e00\u4e2akill\u8bf7\u6c42\u3002MySQL\u4f1a\u5728\u6bcf\u6b21\u7684\u4e3b\u5faa\u73af\u4e2d\u68c0\u67e5kill\u6807\u5fd7\u4f4d\uff0c\u4e0d\u8fc7\u6709\u4e9b\u60c5\u51b5\u4e0b\u8be5\u7ebf\u7a0b\u53ef\u80fd\u4f1a\u8fc7\u4e00\u5c0f\u6bb5\u624d\u80fd\u6b7b\u6389\u3002\u5982\u679c\u8be5\u7ebf\u7a0b\u7a0b\u88ab\u5176\u4ed6\u7ebf\u7a0b\u9501\u4f4f\u4e86\uff0c\u90a3\u4e48kill\u8bf7\u6c42\u4f1a\u5728\u9501\u91ca\u653e\u65f6\u9a6c\u4e0a\u751f\u6548\u3002<br \/>\nLocked<br \/>\n\u88ab\u5176\u4ed6\u67e5\u8be2\u9501\u4f4f\u4e86\u3002<br \/>\nSending data<br \/>\n\u6b63\u5728\u5904\u7406Select\u67e5\u8be2\u7684\u8bb0\u5f55\uff0c\u540c\u65f6\u6b63\u5728\u628a\u7ed3\u679c\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u3002<br \/>\nSorting for group<br \/>\n\u6b63\u5728\u4e3aGROUP BY\u505a\u6392\u5e8f\u3002<br \/>\nSorting for order<br \/>\n\u6b63\u5728\u4e3aORDER BY\u505a\u6392\u5e8f\u3002<br \/>\nOpening tables<br \/>\n\u8fd9\u4e2a\u8fc7\u7a0b\u5e94\u8be5\u4f1a\u5f88\u5feb\uff0c\u9664\u975e\u53d7\u5230\u5176\u4ed6\u56e0\u7d20\u7684\u5e72\u6270\u3002\u4f8b\u5982\uff0c\u5728\u6267Alter TABLE\u6216LOCK TABLE\u8bed\u53e5\u884c\u5b8c\u4ee5\u524d\uff0c\u6570\u636e\u8868\u65e0\u6cd5\u88ab\u5176\u4ed6\u7ebf\u7a0b\u6253\u5f00\u3002\u6b63\u5c1d\u8bd5\u6253\u5f00\u4e00\u4e2a\u8868\u3002<br \/>\nRemoving duplicates<br \/>\n\u6b63\u5728\u6267\u884c\u4e00\u4e2aSelect DISTINCT\u65b9\u5f0f\u7684\u67e5\u8be2\uff0c\u4f46\u662fMySQL\u65e0\u6cd5\u5728\u524d\u4e00\u4e2a\u9636\u6bb5\u4f18\u5316\u6389\u90a3\u4e9b\u91cd\u590d\u7684\u8bb0\u5f55\u3002\u56e0\u6b64\uff0cMySQL\u9700\u8981\u518d\u6b21\u53bb\u6389\u91cd\u590d\u7684\u8bb0\u5f55\uff0c\u7136\u540e\u518d\u628a\u7ed3\u679c\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u3002<br \/>\nReopen table<br \/>\n\u83b7\u5f97\u4e86\u5bf9\u4e00\u4e2a\u8868\u7684\u9501\uff0c\u4f46\u662f\u5fc5\u987b\u5728\u8868\u7ed3\u6784\u4fee\u6539\u4e4b\u540e\u624d\u80fd\u83b7\u5f97\u8fd9\u4e2a\u9501\u3002\u5df2\u7ecf\u91ca\u653e\u9501\uff0c\u5173\u95ed\u6570\u636e\u8868\uff0c\u6b63\u5c1d\u8bd5\u91cd\u65b0\u6253\u5f00\u6570\u636e\u8868\u3002<br \/>\nRepair by sorting<br \/>\n\u4fee\u590d\u6307\u4ee4\u6b63\u5728\u6392\u5e8f\u4ee5\u521b\u5efa\u7d22\u5f15\u3002<br \/>\nRepair with keycache<br \/>\n\u4fee\u590d\u6307\u4ee4\u6b63\u5728\u5229\u7528\u7d22\u5f15\u7f13\u5b58\u4e00\u4e2a\u4e00\u4e2a\u5730\u521b\u5efa\u65b0\u7d22\u5f15\u3002\u5b83\u4f1a\u6bd4Repair by sorting\u6162\u4e9b\u3002<br \/>\nSearching rows for update<br \/>\n\u6b63\u5728\u8bb2\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\u627e\u51fa\u6765\u4ee5\u5907\u66f4\u65b0\u3002\u5b83\u5fc5\u987b\u5728Update\u8981\u4fee\u6539\u76f8\u5173\u7684\u8bb0\u5f55\u4e4b\u524d\u5c31\u5b8c\u6210\u4e86\u3002<br \/>\nSleeping<br \/>\n\u6b63\u5728\u7b49\u5f85\u5ba2\u6237\u7aef\u53d1\u9001\u65b0\u8bf7\u6c42.<br \/>\nSystem lock<br \/>\n\u6b63\u5728\u7b49\u5f85\u53d6\u5f97\u4e00\u4e2a\u5916\u90e8\u7684\u7cfb\u7edf\u9501\u3002\u5982\u679c\u5f53\u524d\u6ca1\u6709\u8fd0\u884c\u591a\u4e2amysqld\u670d\u52a1\u5668\u540c\u65f6\u8bf7\u6c42\u540c\u4e00\u4e2a\u8868\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0&#8211;skip-external-locking\u53c2\u6570\u6765\u7981\u6b62\u5916\u90e8\u7cfb\u7edf\u9501\u3002<br \/>\nUpgrading lock<br \/>\nInsert DELAYED\u6b63\u5728\u5c1d\u8bd5\u53d6\u5f97\u4e00\u4e2a\u9501\u8868\u4ee5\u63d2\u5165\u65b0\u8bb0\u5f55\u3002<br \/>\nUpdating<br \/>\n\u6b63\u5728\u641c\u7d22\u5339\u914d\u7684\u8bb0\u5f55\uff0c\u5e76\u4e14\u4fee\u6539\u5b83\u4eec\u3002<br \/>\nUser Lock<br \/>\n\u6b63\u5728\u7b49\u5f85GET_LOCK()\u3002<br \/>\nWaiting for tables<br \/>\n\u8be5\u7ebf\u7a0b\u5f97\u5230\u901a\u77e5\uff0c\u6570\u636e\u8868\u7ed3\u6784\u5df2\u7ecf\u88ab\u4fee\u6539\u4e86\uff0c\u9700\u8981\u91cd\u65b0\u6253\u5f00\u6570\u636e\u8868\u4ee5\u53d6\u5f97\u65b0\u7684\u7ed3\u6784\u3002\u7136\u540e\uff0c\u4e3a\u4e86\u80fd\u7684\u91cd\u65b0\u6253\u5f00\u6570\u636e\u8868\uff0c\u5fc5\u987b\u7b49\u5230\u6240\u6709\u5176\u4ed6\u7ebf\u7a0b\u5173\u95ed\u8fd9\u4e2a\u8868\u3002\u4ee5\u4e0b\u51e0\u79cd\u60c5\u51b5\u4e0b\u4f1a\u4ea7\u751f\u8fd9\u4e2a\u901a\u77e5\uff1aFLUSH TABLES tbl_name, Alter TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE,\u6216OPTIMIZE TABLE\u3002<br \/>\nwaiting for handler insert<br \/>\nInsert DELAYED\u5df2\u7ecf\u5904\u7406\u5b8c\u4e86\u6240\u6709\u5f85\u5904\u7406\u7684\u63d2\u5165\u64cd\u4f5c\uff0c\u6b63\u5728\u7b49\u5f85\u65b0\u7684\u8bf7\u6c42\u3002<br \/>\n\u5927\u90e8\u5206\u72b6\u6001\u5bf9\u5e94\u5f88\u5feb\u7684\u64cd\u4f5c\uff0c\u53ea\u8981\u6709\u4e00\u4e2a\u7ebf\u7a0b\u4fdd\u6301\u540c\u4e00\u4e2a\u72b6\u6001\u597d\u51e0\u79d2\u949f\uff0c\u90a3\u4e48\u53ef\u80fd\u662f\u6709\u95ee\u9898\u53d1\u751f\u4e86\uff0c\u9700\u8981\u68c0\u67e5\u4e00\u4e0b\u3002<\/p>\n<p>\u5728mysql\u7684\u5b98\u65b9\u6587\u6863\u4e2d\u5217\u51fa\u4e86\u6240\u6709\u53ef\u80fd\u7684\u72b6\u6001\u3002<\/p>\n<h1 class=\"title\">8.14.2\u00a0General Thread States<\/h1>\n<ul>\n<li><a name=\"idm140692604918528\"><\/a>\u00a0<a name=\"idm140692604917040\"><\/a><code>After create<\/code>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.<\/li>\n<li><a name=\"idm140692604913424\"><\/a>\u00a0<a name=\"idm140692604911936\"><\/a><code>Analyzing<\/code>The thread is calculating a\u00a0<code>MyISAM<\/code>\u00a0table key distributions (for example, for<a title=\"13.7.2.1\u00a0ANALYZE TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/analyze-table.html\"><code>ANALYZE TABLE<\/code><\/a>).<\/li>\n<li><a name=\"idm140692604906544\"><\/a>\u00a0<a name=\"idm140692604905056\"><\/a><code>checking permissions<\/code>The thread is checking whether the server has the required privileges to execute the statement.<\/li>\n<li><a name=\"idm140692604901584\"><\/a>\u00a0<a name=\"idm140692604900096\"><\/a><code>Checking table<\/code>The thread is performing a table check operation.<\/li>\n<li><a name=\"idm140692604896672\"><\/a>\u00a0<a name=\"idm140692604895184\"><\/a><code>cleaning up<\/code>The thread has processed one command and is preparing to free memory and reset certain state variables.<\/li>\n<li><a name=\"idm140692604891696\"><\/a>\u00a0<a name=\"idm140692604890208\"><\/a><code>closing tables<\/code>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.<\/li>\n<li><a name=\"idm140692604886592\"><\/a>\u00a0<a name=\"idm140692604885088\"><\/a><code>converting HEAP to MyISAM<\/code>The thread is converting an internal temporary table from a\u00a0<code>MEMORY<\/code>\u00a0table to an on-disk\u00a0<code>MyISAM<\/code>\u00a0table.<\/li>\n<li><a name=\"idm140692604880176\"><\/a>\u00a0<a name=\"idm140692604878688\"><\/a><code>copy to tmp table<\/code>The thread is processing an\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>\u00a0statement. This state occurs after the table with the new structure has been created but before rows are copied into it.<\/li>\n<li><a name=\"idm140692604873920\"><\/a>\u00a0<a name=\"idm140692604872432\"><\/a><code>Copying to group table<\/code>If a statement has different\u00a0<code>ORDER BY<\/code>\u00a0and\u00a0<code>GROUP BY<\/code>\u00a0criteria, the rows are sorted by group and copied to a temporary table.<\/li>\n<li><a name=\"idm140692604867520\"><\/a>\u00a0<a name=\"idm140692604866032\"><\/a><code>Copying to tmp table<\/code>The server is copying to a temporary table in memory.<\/li>\n<li><a name=\"idm140692604862608\"><\/a>\u00a0<a name=\"idm140692604861104\"><\/a><code>Copying to tmp table on disk<\/code>The server is copying to a temporary table on disk. The temporary result set has become too large (see\u00a0<a title=\"8.4.4\u00a0How MySQL Uses Internal Temporary Tables\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/internal-temporary-tables.html\">Section\u00a08.4.4, \u201cHow MySQL Uses Internal Temporary Tables\u201d<\/a>). Consequently, the thread is changing the temporary table from in-memory to disk-based format to save memory.<\/li>\n<li><a name=\"idm140692604856704\"><\/a>\u00a0<a name=\"idm140692604855216\"><\/a><code>Creating index<\/code>The thread is processing\u00a0<code>ALTER TABLE ... ENABLE KEYS<\/code>\u00a0for a\u00a0<code>MyISAM<\/code>table.<\/li>\n<li><a name=\"idm140692604850432\"><\/a><a name=\"idm140692604848944\"><\/a><code>Creating sort index<\/code>The thread is processing a\u00a0<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT<\/code><\/a>\u00a0that is resolved using an internal temporary table.<\/li>\n<li><a name=\"idm140692604844256\"><\/a>\u00a0<a name=\"idm140692604842768\"><\/a><code>creating table<\/code>The thread is creating a table. This includes creation of temporary tables.<\/li>\n<li><a name=\"idm140692604839312\"><\/a>\u00a0<a name=\"idm140692604837824\"><\/a><code>Creating tmp table<\/code>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\u00a0<code>Copying to tmp table on disk<\/code>.<\/li>\n<li><a name=\"idm140692604833504\"><\/a>\u00a0<a name=\"idm140692604832000\"><\/a><code>deleting from main table<\/code>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.<\/li>\n<li><a name=\"idm140692604828368\"><\/a>\u00a0<a name=\"idm140692604826864\"><\/a><code>deleting from reference tables<\/code>The server is executing the second part of a multiple-table delete and deleting the matched rows from the other tables.<\/li>\n<li><a name=\"idm140692604823328\"><\/a>\u00a0<a name=\"idm140692604821824\"><\/a><code>discard_or_import_tablespace<\/code>The thread is processing an\u00a0<code>ALTER TABLE ... DISCARD TABLESPACE<\/code>\u00a0or\u00a0<code>ALTER TABLE ... IMPORT TABLESPACE<\/code>\u00a0statement.<\/li>\n<li><a name=\"idm140692604816896\"><\/a>\u00a0<a name=\"idm140692604815440\"><\/a><code>end<\/code>This occurs at the end but before the cleanup of\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>,\u00a0<a title=\"13.1.12\u00a0CREATE VIEW Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/create-view.html\"><code>CREATE VIEW<\/code><\/a>,\u00a0<a title=\"13.2.2\u00a0DELETE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/delete.html\"><code>DELETE<\/code><\/a>,\u00a0<a title=\"13.2.5\u00a0INSERT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/insert.html\"><code>INSERT<\/code><\/a>,\u00a0<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT<\/code><\/a>, or\u00a0<a title=\"13.2.10\u00a0UPDATE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/update.html\"><code>UPDATE<\/code><\/a>\u00a0statements.<\/li>\n<li><a name=\"idm140692604804688\"><\/a>\u00a0<a name=\"idm140692604803200\"><\/a><code>executing<\/code>The thread has begun executing a statement.<\/li>\n<li><a name=\"idm140692604799792\"><\/a>\u00a0<a name=\"idm140692604798288\"><\/a><code>Execution of init_command<\/code>The thread is executing statements in the value of the\u00a0<code>init_command<\/code>\u00a0system variable.<\/li>\n<li><a name=\"idm140692604794096\"><\/a>\u00a0<a name=\"idm140692604792608\"><\/a><code>freeing items<\/code>The thread has executed a command. Some freeing of items done during this state involves the query cache. This state is usually followed by\u00a0<code>cleaning up<\/code>.<\/li>\n<li><a name=\"idm140692604788368\"><\/a>\u00a0<a name=\"idm140692604786880\"><\/a><code>Flushing tables<\/code>The thread is executing\u00a0<a title=\"13.7.6.2\u00a0FLUSH Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/flush.html\"><code>FLUSH TABLES<\/code><\/a>\u00a0and is waiting for all threads to close their tables.<\/li>\n<li><a name=\"idm140692604782176\"><\/a>\u00a0<a name=\"idm140692604780688\"><\/a><code>FULLTEXT initialization<\/code>The server is preparing to perform a natural-language full-text search.<\/li>\n<li><a name=\"idm140692604777232\"><\/a>\u00a0<a name=\"idm140692604775744\"><\/a><code>init<\/code>This occurs before the initialization of\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>,\u00a0<a title=\"13.2.2\u00a0DELETE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/delete.html\"><code>DELETE<\/code><\/a>,\u00a0<a title=\"13.2.5\u00a0INSERT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/insert.html\"><code>INSERT<\/code><\/a>,<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT<\/code><\/a>, or\u00a0<a title=\"13.2.10\u00a0UPDATE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/update.html\"><code>UPDATE<\/code><\/a>\u00a0statements. Actions taken by the server in this state include flushing the binary log, the\u00a0<code>InnoDB<\/code>\u00a0log, and some query cache cleanup operations.\n<p>For the\u00a0<code>end<\/code>\u00a0state, the following operations could be happening:<\/p>\n<div>\n<ul>\n<li>Removing query cache entries after data in a table is changed<\/li>\n<li>Writing an event to the binary log<\/li>\n<li>Freeing memory buffers, including for blobs<\/li>\n<\/ul>\n<\/div>\n<\/li>\n<li><a name=\"idm140692604761152\"><\/a>\u00a0<a name=\"idm140692604759664\"><\/a><code>Killed<\/code>Someone has sent a\u00a0<a title=\"13.7.6.3\u00a0KILL Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/kill.html\"><code>KILL<\/code><\/a>\u00a0statement 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.<\/li>\n<li><a name=\"idm140692604754672\"><\/a>\u00a0<a name=\"idm140692604753184\"><\/a><code>Locked<\/code>The query is locked by another query.<\/li>\n<li><a name=\"idm140692604749776\"><\/a>\u00a0<a name=\"idm140692604748288\"><\/a><code>logging slow query<\/code>The thread is writing a statement to the slow-query log.<\/li>\n<li><a name=\"idm140692604744864\"><\/a>\u00a0<a name=\"idm140692604743376\"><\/a><code>NULL<\/code>This state is used for the\u00a0<a title=\"13.7.5.27\u00a0SHOW PROCESSLIST Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/show-processlist.html\"><code>SHOW PROCESSLIST<\/code><\/a>\u00a0state.<\/li>\n<li><a name=\"idm140692604738736\"><\/a>\u00a0<a name=\"idm140692604737248\"><\/a><code>login<\/code>The initial state for a connection thread until the client has been authenticated successfully.<\/li>\n<li><a name=\"idm140692604733776\"><\/a>\u00a0<a name=\"idm140692604732288\"><\/a><a name=\"idm140692604730800\"><\/a><a name=\"idm140692604729312\"><\/a><code>Opening tables<\/code>,\u00a0<code>Opening table<\/code>The thread is trying to open a table. This is should be very fast procedure, unless something prevents opening. For example, an\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>\u00a0or a<a title=\"13.3.5\u00a0LOCK TABLES and UNLOCK TABLES Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/lock-tables.html\"><code>LOCK TABLE<\/code><\/a>\u00a0statement can prevent opening a table until the statement is finished. It is also worth checking that your\u00a0<a href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/server-system-variables.html#sysvar_table_cache\"><code>table_cache<\/code><\/a>\u00a0value is large enough.<\/li>\n<li><a name=\"idm140692604721264\"><\/a>\u00a0<a name=\"idm140692604719776\"><\/a><code>optimizing<\/code>The server is performing initial optimizations for a query.<\/li>\n<li><a name=\"idm140692604716352\"><\/a>\u00a0<a name=\"idm140692604714864\"><\/a><code>preparing<\/code>This state occurs during query optimization.<\/li>\n<li><a name=\"idm140692604711456\"><\/a>\u00a0<a name=\"idm140692604709968\"><\/a><code>Purging old relay logs<\/code>The thread is removing unneeded relay log files.<\/li>\n<li><a name=\"idm140692604706544\"><\/a>\u00a0<a name=\"idm140692604705056\"><\/a><code>query end<\/code>This state occurs after processing a query but before the\u00a0<code>freeing items<\/code>state.<\/li>\n<li><a name=\"idm140692604700912\"><\/a>\u00a0<a name=\"idm140692604699424\"><\/a><code>Reading from net<\/code>The server is reading a packet from the network.<\/li>\n<li><a name=\"idm140692604696000\"><\/a>\u00a0<a name=\"idm140692604694512\"><\/a><code>Removing duplicates<\/code>The query was using\u00a0<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT DISTINCT<\/code><\/a>\u00a0in 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.<\/li>\n<li><a name=\"idm140692604689632\"><\/a>\u00a0<a name=\"idm140692604688144\"><\/a><code>removing tmp table<\/code>The thread is removing an internal temporary table after processing a\u00a0<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT<\/code><\/a>\u00a0statement. This state is not used if no temporary table was created.<\/li>\n<li><a name=\"idm140692604683376\"><\/a>\u00a0<a name=\"idm140692604681888\"><\/a><code>rename<\/code>The thread is renaming a table.<\/li>\n<li><a name=\"idm140692604678496\"><\/a>\u00a0<a name=\"idm140692604677008\"><\/a><code>rename result table<\/code>The thread is processing an\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>\u00a0statement, has created the new table, and is renaming it to replace the original table.<\/li>\n<li><a name=\"idm140692604672288\"><\/a>\u00a0<a name=\"idm140692604670800\"><\/a><code>Reopen tables<\/code>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.<\/li>\n<li><a name=\"idm140692604667216\"><\/a>\u00a0<a name=\"idm140692604665728\"><\/a><code>Repair by sorting<\/code>The repair code is using a sort to create indexes.<\/li>\n<li><a name=\"idm140692604662304\"><\/a>\u00a0<a name=\"idm140692604660816\"><\/a><code>Repair done<\/code>The thread has completed a multi-threaded repair for a\u00a0<code>MyISAM<\/code>\u00a0table.<\/li>\n<li><a name=\"idm140692604656672\"><\/a>\u00a0<a name=\"idm140692604655184\"><\/a><code>Repair with keycache<\/code>The repair code is using creating keys one by one through the key cache. This is much slower than\u00a0<code>Repair by sorting<\/code>.<\/li>\n<li><a name=\"idm140692604650976\"><\/a>\u00a0<a name=\"idm140692604649488\"><\/a><code>Rolling back<\/code>The thread is rolling back a transaction.<\/li>\n<li><a name=\"idm140692604646080\"><\/a>\u00a0<a name=\"idm140692604644592\"><\/a><code>Saving state<\/code>For\u00a0<code>MyISAM<\/code>\u00a0table operations such as repair or analysis, the thread is saving the new table state to the\u00a0<code>.MYI<\/code>\u00a0file header. State includes information such as number of rows, the\u00a0<code>AUTO_INCREMENT<\/code>\u00a0counter, and key distributions.<\/li>\n<li><a name=\"idm140692604638864\"><\/a>\u00a0<a name=\"idm140692604637360\"><\/a><code>Searching rows for update<\/code>The thread is doing a first phase to find all matching rows before updating them. This has to be done if the\u00a0<a title=\"13.2.10\u00a0UPDATE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/update.html\"><code>UPDATE<\/code><\/a>\u00a0is changing the index that is used to find the involved rows.<\/li>\n<li><code>Sending data<\/code>The thread is reading and processing rows for a\u00a0<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT<\/code><\/a>\u00a0statement, and sending data to the client. Because operations occurring during this this state tend to perform large amounts of disk access (reads), it is often the longest-running state over the lifetime of a given query.<\/li>\n<li><a name=\"idm140692604629104\"><\/a>\u00a0<a name=\"idm140692604627616\"><\/a><code>setup<\/code>The thread is beginning an\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>\u00a0operation.<\/li>\n<li><a name=\"idm140692604622992\"><\/a>\u00a0<a name=\"idm140692604621504\"><\/a><code>Sorting for group<\/code>The thread is doing a sort to satisfy a\u00a0<code>GROUP BY<\/code>.<\/li>\n<li><a name=\"idm140692604617392\"><\/a>\u00a0<a name=\"idm140692604615904\"><\/a><code>Sorting for order<\/code>The thread is doing a sort to satisfy a\u00a0<code>ORDER BY<\/code>.<\/li>\n<li><a name=\"idm140692604611792\"><\/a>\u00a0<a name=\"idm140692604610304\"><\/a><code>Sorting index<\/code>The thread is sorting index pages for more efficient access during a\u00a0<code>MyISAM<\/code>table optimization operation.<\/li>\n<li><a name=\"idm140692604606112\"><\/a>\u00a0<a name=\"idm140692604604624\"><\/a><code>Sorting result<\/code>For a\u00a0<a title=\"13.2.8\u00a0SELECT Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/select.html\"><code>SELECT<\/code><\/a>\u00a0statement, this is similar to\u00a0<code>Creating sort index<\/code>, but for nontemporary tables.<\/li>\n<li><a name=\"idm140692604599248\"><\/a>\u00a0<a name=\"idm140692604597760\"><\/a><code>statistics<\/code>The server is calculating statistics to develop a query execution plan. If a thread is in this state for a long time, the server is probably disk-bound performing other work.<\/li>\n<li><a name=\"idm140692604594176\"><\/a>\u00a0<a name=\"idm140692604593104\"><\/a><a name=\"idm140692604591616\"><\/a><a name=\"idm140692604590128\"><\/a><code>System lock<\/code>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\u00a0<a title=\"4.3.1\u00a0mysqld \u2014 The MySQL Server\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/mysqld.html\"><strong>mysqld<\/strong><\/a>\u00a0servers that are accessing the same\u00a0<a title=\"14.1\u00a0The MyISAM Storage Engine\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/myisam-storage-engine.html\"><code>MyISAM<\/code><\/a>\u00a0tables, you can disable external system locks with the\u00a0<a href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/server-options.html#option_mysqld_external-locking\"><code>--skip-external-locking<\/code><\/a>\u00a0option. However, external locking is disabled by default, so it is likely that this option will have no effect. For\u00a0<a title=\"13.7.5.28\u00a0SHOW PROFILE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/show-profile.html\"><code>SHOW PROFILE<\/code><\/a>, this state means the thread is requesting the lock (not waiting for it).<\/li>\n<li><a name=\"idm140692604581520\"><\/a>\u00a0<a name=\"idm140692604580032\"><\/a><code>Table lock<\/code>The next thread state after\u00a0<code>System lock<\/code>. The thread has acquired an external lock and is going to request an internal table lock.<\/li>\n<li><a name=\"idm140692604575808\"><\/a>\u00a0<a name=\"idm140692604574320\"><\/a><code>update<\/code>The thread is getting ready to start updating the table.<\/li>\n<li><a name=\"idm140692604570896\"><\/a>\u00a0<a name=\"idm140692604569408\"><\/a><code>Updating<\/code>The thread is searching for rows to update and is updating them.<\/li>\n<li><a name=\"idm140692604565968\"><\/a>\u00a0<a name=\"idm140692604564480\"><\/a><code>updating main table<\/code>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.<\/li>\n<li><a name=\"idm140692604560880\"><\/a>\u00a0<a name=\"idm140692604559376\"><\/a><code>updating reference tables<\/code>The server is executing the second part of a multiple-table update and updating the matched rows from the other tables.<\/li>\n<li><a name=\"idm140692604555840\"><\/a>\u00a0<a name=\"idm140692604554352\"><\/a><code>User lock<\/code>The thread is going to request or is waiting for an advisory lock requested with a\u00a0<a href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/miscellaneous-functions.html#function_get-lock\"><code>GET_LOCK()<\/code><\/a>\u00a0call. For\u00a0<a title=\"13.7.5.28\u00a0SHOW PROFILE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/show-profile.html\"><code>SHOW PROFILE<\/code><\/a>, this state means the thread is requesting the lock (not waiting for it).<\/li>\n<li><a name=\"idm140692604548320\"><\/a>\u00a0<a name=\"idm140692604546816\"><\/a><code>Waiting for release of readlock<\/code>The thread is waiting for a global read lock obtained by another thread (with<a title=\"13.7.6.2\u00a0FLUSH Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/flush.html\"><code>FLUSH TABLES WITH READ LOCK<\/code><\/a>) to be released.<\/li>\n<li><a name=\"idm140692604542064\"><\/a>\u00a0<a name=\"idm140692604540576\"><\/a><a name=\"idm140692604539088\"><\/a><a name=\"idm140692604537600\"><\/a><code>Waiting for tables<\/code>,\u00a0<code>Waiting for table<\/code>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.\n<p>This notification takes place if another thread has used\u00a0<a title=\"13.7.6.2\u00a0FLUSH Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/flush.html\"><code>FLUSH TABLES<\/code><\/a>\u00a0or one of the following statements on the table in question:\u00a0<code>FLUSH TABLES<em><code>tbl_name<\/code><\/em><\/code>,\u00a0<a title=\"13.1.4\u00a0ALTER TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/alter-table.html\"><code>ALTER TABLE<\/code><\/a>,\u00a0<a title=\"13.1.20\u00a0RENAME TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/rename-table.html\"><code>RENAME TABLE<\/code><\/a>,\u00a0<a title=\"13.7.2.6\u00a0REPAIR TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/repair-table.html\"><code>REPAIR TABLE<\/code><\/a>,\u00a0<a title=\"13.7.2.1\u00a0ANALYZE TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/analyze-table.html\"><code>ANALYZE TABLE<\/code><\/a>, or\u00a0<a title=\"13.7.2.5\u00a0OPTIMIZE TABLE Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/optimize-table.html\"><code>OPTIMIZE TABLE<\/code><\/a>.<\/li>\n<li><a name=\"idm140692604524256\"><\/a>\u00a0<a name=\"idm140692604522768\"><\/a><code>Waiting on cond<\/code>A generic state in which the thread is waiting for a condition to become true. No specific state information is available.<\/li>\n<li><a name=\"idm140692604519248\"><\/a>\u00a0<a name=\"idm140692604517760\"><\/a><code>Waiting to get readlock<\/code>The thread has issued a\u00a0<a title=\"13.7.6.2\u00a0FLUSH Syntax\" href=\"\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/flush.html\"><code>FLUSH TABLES WITH READ LOCK<\/code><\/a>\u00a0statement to obtain a global read lock and is waiting to obtain the lock.<\/li>\n<li><a name=\"idm140692604513040\"><\/a>\u00a0<a name=\"idm140692604511552\"><\/a><code>Writing to net<\/code>The server is writing a packet to the network.<\/li>\n<\/ul>\n<p>[root@ucjmh ~]# cat kill_lock.sql<br \/>\nkill 43;<br \/>\nkill 55;<br \/>\n[root@ucjmh ~]# cat locked.txt<br \/>\n43 root localhost hi_db Query 3825 Waiting for table metadata lock insert into t values(4)<br \/>\n55 root localhost NULL Query 0 NULL show processlist<br \/>\n[root@ucjmh ~]# cat ger_lock.sh<br \/>\n#!\/bin\/bash<br \/>\nrm -rf locked.txt<br \/>\nrm -rf kill_lock.sql<br \/>\nmysql -uroot -poracle -e &#8220;show processlist&#8221;|grep -i &#8220;Query&#8221; &gt;&gt; locked.txt;<br \/>\nfor line in $(awk &#8216;{printf $1&#8243;\\n&#8221;}&#8217; locked.txt)<br \/>\ndo<br \/>\necho &#8220;kill ${line};&#8221;&gt;&gt;kill_lock.sql<br \/>\ndone<\/p>\n","protected":false},"excerpt":{"rendered":"<p>processlist\u547d\u4ee4\u7684\u8f93\u51fa\u7ed3\u679c\u663e\u793a\u4e86\u6709\u54ea\u4e9b\u7ebf\u7a0b\u5728\u8fd0\u884c\uff0c\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u51fa\u6709\u95ee\u9898\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u4e24\u79cd\u65b9\u5f0f\u4f7f\u7528\u8fd9\u4e2a\u547d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[27],"class_list":["post-885","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=885"}],"version-history":[{"count":1,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/885\/revisions"}],"predecessor-version":[{"id":890,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/885\/revisions\/890"}],"wp:attachment":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=885"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}