我正在尝试优化此查询 - 目前需要大约10秒才能完成。
我认为减速来自REGEXP - all_artists字段中的数据格式为artist1 | artist2 | artist3
SELECT * FROM releases WHERE (all_artists REGEXP
(SELECT GROUP_CONCAT(releases.artist SEPARATOR '|')
FROM releases
INNER JOIN charts_extended
ON charts_extended.release_id=releases.id
WHERE charts_extended.artist='Quickinho'
AND releases.all_artists!='Various Artists')
OR label_no_country IN
(SELECT releases.label_no_country
FROM releases
INNER JOIN charts_extended
ON charts_extended.release_id=releases.id
WHERE charts_extended.artist='Quickinho'))
AND releases.id NOT IN (SELECT release_id FROM charts_extended WHERE artist='Quickinho') ORDER BY date DESC LIMIT 0,102