我有这样的查询
SELECT VID, title, duration, addtime, thumb, thumbs,
viewnumber, rate, likes, dislikes, type, hd
FROM video WHERE active = '1' AND type = 'public'
ORDER BY addtime DESC
LIMIT 2052, 36;
当我用heidisql运行解释时,结果是:
/* Affected rows: 0 Found rows: 1 Warnings: 0 Duration for 2 queries: 0.999 sec. */
Using index condition; Using where; Using filesort
它里面有文件包,它会影响性能吗?如果是的话,如何摆脱它?
答案 0 :(得分:1)
当读取索引顺序中的行并不符合您的查询所请求的ORDER BY
时,MySQL会使用filesort。
在您显示的示例查询中,您可以通过添加此索引来避免文件排序:
ALTER TABLE video ADD INDEX (active, type, addtime);