利用mytop监测mysql运行状态,发现有几句经常会出现在里面,时间不长,1秒的时候就会消失了。我随后拿着这几条SQL来单测试,速度都在0点几秒时间内。之后我发现show processlist,状态是处于preparing状态,然后消失。。网上搜索了很多都很少关于preparing状态的介绍,只是在MYSQL手册里面简单描述了,在运行中进行优化。这几条SQL一直导致CPU占用100%以上。。找不到解决思路,问preparing是怎么回事,各大虾有什么思路不?
解决方案 »
- Mysql中文乱码的解决方法
- 请介绍几本SQL的书籍
- insert 的时候奇怪的问题!
- 关于MYSQL 的检查check约束
- 同一机器安装了mysql4.0.16与mysql5.0.18后,有一个问题不明白?
- shape格式地图无法导入Postgresql数据库
- 通过网络访问mysql数据库
- ###~诸位高高手近来帮忙~唯一的一点分了~全给~
- 谁有sql-92 的标准(specification)?给个url也行!
- 有谁在win2k下用apache-mysql-php4这个软件配置过php,安装完后应该怎么指向?
- mysql每次都要点击mysqld-nd.exe才能进入服务
- 用Mysql还原.sql文件?.sql文件在其他文件夹
不过有样东西就是explain出来的东西,我觉得有点奇怪
explain select count(*) total from product p left join product_description pd on (p.product_id = pd.product_id) where pd.language_id = 1 and p.product_id IN (SELECT p2c.product_id FROM product_to_category p2c WHERE p2c.category_id = '218' or p2c.category_id = '220');+----+--------------------+-------+----------------+--------------------------------+------------+---------+--------------------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+--------------------+-------+----------------+--------------------------------+------------+---------+--------------------------------+------+--------------------------+
| 1 | PRIMARY | p | index | PRIMARY | PRIMARY | 4 | NULL | 9771 | Using where; Using index |
| 1 | PRIMARY | pd | eq_ref | PRIMARY | PRIMARY | 8 | fashione_db.p.product_id,const | 1 | Using where; Using index |
| 2 | DEPENDENT SUBQUERY | p2c | index_subquery | PRIMARY,category_id,product_id | product_id | 4 | func | 1 | Using where |
+----+--------------------+-------+----------------+--------------------------------+------------+---------+--------------------------------+------+--------------------------+explain 出来的结果里面有个表product的type类型是index,这叫正常吗?而且检索的行也很多。。我感觉不正常。
explain+----+--------------------+-------+----------------+--------------------------------+------------+---------+----------------------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+--------------------+-------+----------------+--------------------------------+------------+---------+----------------------------------+------+--------------------------+
| 1 | PRIMARY | p2s | index | PRIMARY,store_id | PRIMARY | 8 | NULL | 7360 | Using where; Using index |
| 1 | PRIMARY | p | eq_ref | PRIMARY,date_available | PRIMARY | 4 | fashione_db.p2s.product_id | 1 | Using where |
| 1 | PRIMARY | ps | ref | product_id | product_id | 4 | fashione_db.p.product_id | 1 | Using index |
| 1 | PRIMARY | pd | eq_ref | PRIMARY | PRIMARY | 8 | fashione_db.p2s.product_id,const | 1 | Using where; Using index |
| 2 | DEPENDENT SUBQUERY | p2c | index_subquery | PRIMARY,category_id,product_id | product_id | 4 | func | 1 | Using where |
+----+--------------------+-------+----------------+--------------------------------+------------+---------+----------------------------------+------+--------------------------+
5 rows in set (0.00 sec)
检索有7000多条。。感觉不太好,但应该不会导致CPU那么高啊。求解释。