这个查询会死掉,除非我在它之前重启MySQL。如果只是运行它,它会超时,但如果我重新启动然后运行它,它会在不到一秒的时间内完成。
select
u.id as wp_id,
(select user_id from htts_private_003.Purchasers_wp_phpbb3 where id=u.id and user_id is not null order by user_id desc limit 1) as user_id,
count(*)
FROM
`auto-19414-1`.`wp_users` u
left join htts_private_003.User_accounts_wp_bb ui on u.id =ui.wp_id
where ui.wp_id is null
and (select user_id from htts_private_003.Purchasers_wp_phpbb3 where id=u.id and user_id is not null order by user_id desc limit 1) is not null
group by (select user_id
from htts_private_003.Purchasers_wp_phpbb3 where id=u.id order by user_id desc limit 1)
having count(*) = 1
如何找出问题并解决问题?我放入谷歌的任何内容都没有带回任何解释这一点,我希望有人可以帮助
所涉及的所有字段都有索引。好像索引已经消失,重新启动会将它们带回来。我不知道重启时创建的索引......所以我被卡住了。
EXPLAIN 以下是使用EXPLAIN和MySQL进行此查询时返回的内容: