MyException - 我的反常网
当时方位:我的反常网» MySQL » mysql中查询联接作业状况

mysql中查询联接作业状况

www.x8vin4.com  网友共享于:2018-06-08  阅读:0次
mysql中查询衔接作业状况
#!/bin/bash
while true
do
mysql -uroot -e 'show processlist\G'|grep State:|uniq -c|sort -rn
echo '---'
sleep 1
Done


假如观察到以下状况,则需要注意
converting HEAP to MyISAM 查询成果太大时,把成果放在磁盘 (句子写的欠好,取数据太多)
create tmp table             创立暂时表(如group时贮存中心成果,阐明索引建的欠好)
Copying to tmp table on disk   把内存暂时表复制到磁盘 (索引欠好,表字段选的欠好)
locked         被其他查询锁住 (一般在运用业务时易发作,互联网运用不常发作)
logging slow query 记载慢查询
mysql 5.5 今后加了一个profile设置,能够观察到详细句子的履行进程.
0:检查profile是否敞开

> Show  variables like ‘profiling’
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| profiling     | OFF   |
+---------------+-------+

1:> set profiling=on;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| profiling     | On      |
+---------------+-------+


mysql> show profiles;
+----------+------------+----------------------------------------------------------+
| Query_ID | Duration   | Query                                                    |
+----------+------------+----------------------------------------------------------+
|        1 | 0.00034225 | select cat_id,avg(shop_price) from goods group by cat_id |
+----------+------------+----------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show profile for query 1;
+----------------------+----------+
| Status               | Duration |
+----------------------+----------+
| starting             | 0.000058 |
| checking permissions | 0.000008 |
...
...
| Sorting result       | 0.000004 |
| Sending data         | 0.000120 |
| end                  | 0.000005 |
| query end            | 0.000006 |
| closing tables       | 0.000008 |
| freeing items        | 0.000023 |
| logging slow query   | 0.000003 |
| cleaning up          | 0.000004 |
+----------------------+----------+
m88 188bet uedbet 威廉希尔 明升 bwin 明升88 bodog bwin 明升m88.com 18luck 188bet unibet unibet Ladbrokes Ladbrokes casino m88明升 明升 明升 m88.com 188bet m88 明陞 uedbet赫塔菲官网 365bet官网 m88 help

文章谈论

软件开发程序过错反常ExceptionCopyright © 2009-2015 MyException 版权所有