title: Laravel Join tables and group by sum query too slow
body: <p>I am using Laravel query builder to get desired results from database. The following query if working perfectly but taking too much time to get results. Can you please help me with this?</p>
  <pre class="lang-sql prettyprint-override"><code>select 
    `amz_ads_sp_campaigns`.*, 
    SUM(attributedUnitsOrdered7d) as order7d, 
    SUM(attributedUnitsOrdered30d) as order30d, 
    SUM(attributedSales7d) as sale7d, 
    SUM(attributedSales30d) as sale30d, 
    SUM(impressions) as impressions, 
    SUM(clicks) as clicks, 
    SUM(cost) as cost, 
    SUM(attributedConversions7d) as attributedConversions7d, 
    SUM(attributedConversions30d) as attributedConversions30d 
  from 
    `amz_ads_sp_product_targetings` 
    inner join `amz_ads_sp_report_product_targetings` on `amz_ads_sp_product_targetings`.`campaignId` = `amz_ads_sp_report_product_targetings`.`campaignId` 
    inner join `amz_ads_sp_campaigns` on `amz_ads_sp_report_product_targetings`.`campaignId` = `amz_ads_sp_campaigns`.`campaignId` 
  where 
    (
      `amz_ads_sp_product_targetings`.`user_id` = ? 
      and `amz_ads_sp_product_targetings`.`profileId` = ?
    ) 
  group by 
    `amz_ads_sp_product_targetings`.`campaignId`
  
  </code></pre>
  <p><strong>Result of Explain SQL</strong></p>
  <pre><code>
  id  select_type table                   type    possible_keys   key     key_len     ref                         rows    Extra   
  1   SIMPLE      amz_ads_sp_report_product_targetings    ALL campaignId  NULL        NULL        NULL                            50061   Using temporary; Using filesort
  1   SIMPLE      amz_ads_sp_campaigns            ref campaignId  campaignId  8       pr-amz-ppc.amz_ads_sp_report_product_targetings.ca...   1   
  1   SIMPLE      amz_ads_sp_product_targetings       ref campaignId  campaignId  8       pr-amz-ppc.amz_ads_sp_report_product_targetings.ca...   33  Using where
  </code></pre>