title: What Won't this Query Run Without Restarting MySQL
body: <p>This query dies, unless I restart MySQL just before it.  If just run it, it times out, but if I restart then run it, it completes in less than a  seconds.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>How do I figure out the problem and solve it?   Nothing I put into Google brings back anything explaining this, I am hoping someone here can help</p>
  
  <p>There are indexes on all the fields involved.  It is as if the indexes are gone and a restart brings them back.  I don't know of indexes created on restart... so I am stuck.</p>
  
  <p>EXPLAIN
  Here is what came back when using EXPLAIN with MySQL for this query:
  <img src="https://i.stack.imgur.com/g93py.png" alt="image of the EXPLAIN results"></p>