title: I need a MySQL query to be optimized
body: <p>I have a query running on MySQL DB and is very slow.</p>
  
  <p>Is there anyway I can optimize the following</p>
  
  <pre><code>SELECT mcm.merchant_name,
     ( ( Sum(ot.price) + Sum(ot.handling_charges)
         + Sum(ot.sales_tax_recd)
         + Sum(ot.shipping_cost) - Sum(ot.sales_tax_payable) ) -
       Sum(im.break_even_cost) ) AS PL,
     ot.merchant_id
     FROM   order_table ot,
            item_master im,
            merchant_master mcm
     WHERE  ot.item_id = im.item_id
     AND ot.merchant_id = mcm.merchant_id
     GROUP  BY mcm.merchant_name
     ORDER  BY pl DESC
     LIMIT  0, 10; 
  </code></pre>
  
  <p>The Above Query is taking more than 200 seconds to execute.</p>
  
  <p>Explain Result:</p>
  
  <pre><code>id  select_type table   type    possible_keys           key         key_len     ref                     rows        Extra   
  1   SIMPLE      ot      ALL     "merchant_id,item_id"   NULL        NULL        NULL                    507910      "Using temporary; Using filesort"
  1   SIMPLE      mcm     eq_ref  "PRIMARY,merchant_id"   PRIMARY     4           stores.ot.merchant_id   1   
  1   SIMPLE      im      eq_ref  "PRIMARY,item_id"       PRIMARY     4           stores.ot.item_id       1   
  </code></pre>
  
  <p>Also, I got Error-1003 when I run EXPLAIN EXTENDED</p>