syvin
发贴: 41
积分: 1
|
于 2007-12-25 20:11
同样一个sql语句,在本地explain和网上explain结果不一致,使用网上数据过程中,开始非常快,没有filesort问题,说明网上也是按照本地的explain方式解析的,20分钟后变得很慢了。(整个过程是连续的查询,一次50条)
不知道哪位大虾知道为什么么?
测试环境—— mysql> explain SELECT ssi.catid,ssi.dateline,ssi.subject,ssi.type,ssi.uid,ssi.username,ssb.* FROM supe_spaceitems as ssi,supe_spaceblogs as ssb WHERE ssi.itemid>427091 AND ssi.itemid=ssb.itemid ORDER BY ssi.itemid LIMIT 50; +----+-------------+-------+--------+---------------+---------+---------+-------------------+-------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+---------------+---------+---------+-------------------+-------+-------------+ | 1 | SIMPLE | ssi | range | PRIMARY | PRIMARY | 3 | NULL | 89664 | Using where | | 1 | SIMPLE | ssb | eq_ref | PRIMARY | PRIMARY | 3 | blogdb.ssi.itemid | 1 | | +----+-------------+-------+--------+---------------+---------+---------+-------------------+-------+-------------+ mysql> select count from supe_spaceblogs; +----------+ | count | +----------+ | 372948 | +----------+ 1 row in set (0.00 sec)
mysql> select count from supe_spaceitems; +----------+ | count | +----------+ | 496222 | +----------+ 1 row in set (0.00 sec)
网上环境—— mysql> explain SELECT ssi.catid,ssi.dateline,ssi.subject,ssi.type,ssi.uid,ssi.username,ssb.* FROM supe_spaceitems as ssi,supe_spaceblogs as ssb WHERE ssi.itemid>426945 AND ssi.itemid=ssb.itemid ORDER BY ssi.itemid LIMIT 50; +----+-------------+-------+--------+---------------+---------+---------+-------------------+--------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+---------------+---------+---------+-------------------+--------+----------------------------------------------+ | 1 | SIMPLE | ssb | range | PRIMARY | PRIMARY | 3 | NULL | 237193 | Using where; Using temporary; Using filesort | | 1 | SIMPLE | ssi | eq_ref | PRIMARY | PRIMARY | 3 | blogdb.ssb.itemid | 1 | | +----+-------------+-------+--------+---------------+---------+---------+-------------------+--------+----------------------------------------------+ 2 rows in set (0.68 sec)
mysql> select count from supe_spaceblogs; +----------+ | count | +----------+ | 489008 | +----------+ 1 row in set (0.00 sec)
mysql> select count from supe_spaceitems; +----------+ | count | +----------+ | 640462 | +----------+ 1 row in set (0.33 sec)
syvin edited on 2007-12-25 20:19
|