作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下查询需要帮助。
SELECT a.artist, a.facepic
FROM artists_vs AS v, artists AS a
WHERE v.genreid =0
AND (v.artistid1 = a.artistid OR v.artistid2 = a.artistid)
ORDER BY v.bid DESC
LIMIT 20
查询中的所有字段都已建立索引,但是当我运行解释时,我得到以下结果:
1 SIMPLE v ref genreid,artistid1,artistid2 genreid 4 const 15 Using temporary; Using filesort
1 SIMPLE a ALL PRIMARY NULL NULL NULL 18165 Range checked for each record (index map: 0x1)
我需要在 my.cnf 中启用 log-queries-not-using-indexes
任何人都可以建议我如何重写此查询以使其远离慢速日志吗?
最佳答案
你可以尝试这样的事情:
SELECT
a.artist,
a.facepic,
V.bid
FROM artists_vs AS v
inner join artists as a on v.artistid1 = a.artistid
WHERE v.genreid = 0
union
SELECT
a.artist,
a.facepic,
v.bid
FROM artists_vs AS v
inner join artists as a on v.artistid2 = a.artistid
WHERE v.genreid = 0
ORDER BY bid DESC
LIMIT 20
关于mysql - 如何将此类查询排除在 mysql_slow.log 之外?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4764191/
我是一名优秀的程序员,十分优秀!