小编lpa*_*lpa的帖子

MySQL:无法在简单查询中摆脱“使用文件排序”

简单查询但无法摆脱“using filesort”:

CREATE TABLE IF NOT EXISTS `online` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL,
  `expiration` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  KEY `expiration` (`expiration`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1925234 ;

mysql> explain SELECT i.id, i.uid, i.expiration, u.nick, u.mainpicture
    -> FROM online i join usertable u on i.uid = u.id
    -> order by i.expiration DESC limit 0,12;

+----+-------------+-------+--------+---------------+---------+---------+----------------+------+----------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref …
Run Code Online (Sandbox Code Playgroud)

mysql performance query-performance

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

mysql ×1

performance ×1

query-performance ×1