我想我遇到了这个 MySql bug,但解决方案引用了一个不再存在的评论。有谁知道解决方案是什么?
我的特定用例涉及带有回合的游戏。我想找到在“动作”事件之后没有“不作为”事件的所有(游戏、回合)对。这是我的查询:
SELECT
*
FROM
(
SELECT
MAX(id) AS id,
game_id,
round
FROM event
WHERE
type_of="Action"
GROUP BY
game_id, round
) AS last_action
LEFT JOIN (
SELECT
MAX(id) AS id,
game_id,
round
FROM event
WHERE
type_of="Inaction"
GROUP BY
game_id, round
) AS last_inaction
USING
(game_id, round)
WHERE
last_inaction.id IS NULL
OR last_action.id > last_inaction.id;
这运行非常缓慢,并且有一个解释,包括Using where; Using join buffer (Block Nested Loop). 但是,如果我将查询的 WHERE 语句编辑为功能等效的
WHERE
last_inaction.id IS NULL
OR last_action.id > last_inaction.id + 0;
查询几乎立即执行并且不包括Using where; Using join buffer (Block Nested Loop).