title: Optimalize MySQL query
body: <p>I have one query, that is comparatively slow. I tried to rewrite it many times, but I cant find better solution. So I want to ask you, if it is written in wrong way from the beginning or it is ok.</p>
  
  <pre><code>    SELECT sql_calc_found_rows 
      present_id, present_id, present_url, present_name, present_text_short, foto_name, price_id, price_price, price_amount, price_dis 
      FROM a_present 
      LEFT JOIN 
         (SELECT price_id, price_present_id, price_supplier_id, price_dis, price_amount, 
          (CASE WHEN price_dis &lt;&gt; 0 THEN price_dis ELSE price_amount END) as price_price 
         FROM a_price 
         WHERE 
         price_visibility = 1 AND price_deleted &lt;&gt; 1 
         GROUP BY price_id ) pri 
      ON pri.price_present_id = present_id 
      LEFT JOIN _present_fotos ON foto_id = present_title_foto 
      LEFT JOIN _cate_pres ON cp_present = present_id 
      WHERE present_visibility = 1 AND present_deleted &lt;&gt; 1 AND price_price &gt; 0 AND present_out &lt;&gt; 1 AND cp_category IN (30,31,232,32) 
      GROUP BY present_id 
      ORDER BY price_price 
      LIMIT 8
  </code></pre>
  
  <p>Description: price_dis is price after discount, price_amount is price before discount.. Each product (present) has more prices than one.. Is there faster solution to select final price?</p>
  
  <p>If you will find table structure bad, I will be in trouble:)</p>
  
  <p>Thank you very much!</p>
  
  <p>EDIT:
  <a href="http://postimg.org/image/q1spybh4p/" rel="nofollow">explain select</a></p>