gpt4 book ai didi

mysql - 如何将此类查询排除在 mysql_slow.log 之外?

转载 作者:行者123 更新时间:2023-11-29 14:55:23 25 4
gpt4 key购买 nike

我有以下查询需要帮助。

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com