title: mysql long time query
body: <p>I have a query on my PHP script it takes too long time!
  When I run the query, server load time increase and server goes down!</p>
  
  <p><strong>Note:</strong> these fields are index: t1.submits_id,t4.submit_id,t3.userid,t1.user_id,owner_id,invited_id,agreed,t2.users_id,,t1.sent_timestamp</p>
  
  <pre><code>SELECT
  t1.submits_id,t1.user_id,is_html,shared_from,type,contents,url,sent_timestamp,show_type,album_cached_info,
  t2.users_id,name,t2.active,page_url,
  t3.time,
  t4.like_time
  FROM iv6_submits as t1 LEFT JOIN iv6_likes as t4 ON (t1.submits_id = t4.submit_id AND t4.user_id=1)
  
  ,iv6_users as t2 LEFT JOIN iv6_onlineusers as t3 ON (t2.users_id=t3.userid)
  WHERE
  t1.submits_id&lt;19000 AND 
  (t1.user_id=1 OR t1.user_id in
      (select IF(owner_id=1,invited_id,owner_id) as id
          from iv6_add_lists
              where ((owner_id=1 or invited_id=1) AND agreed=1) OR (owner_id=1 AND agreed=2)))
  AND t2.users_id=t1.user_id
  ORDER BY t1.sent_timestamp DESC LIMIT 10
  </code></pre>