title: MySQL query is taking too long and unable to retrieve the data
body: <p>I've tried multiple ways of running below query but it doesn't extract the output as shown below. I've tried to check execution plan of it which looks fine.</p>
  
  <p><img src="https://i.stack.imgur.com/mcd2j.png" alt="image"></p>
  
  <p>My code:</p>
  
  <pre><code>SELECT
  SUM(case when cp.payment_method_id_fk = 3 then dt.amount_attempted else 0 end)  AS Subsequent_successDeduction_TIGO,
  SUM(case when cp.payment_method_id_fk = 2 then dt.amount_attempted else 0 end)  AS Subsequent_successDeduction_MTN,
     date(dt.transaction_date) AS DateOfTransactions
  FROM deduction_transactions dt INNER JOIN customer_deductions cd ON
     dt.deduction_id_fk = cd.id INNER JOIN customer_policy cp ON
     cd.cust_policy_id = cp.customer_policy_id
     inner join  policy_info pi ON cp.policy_id_fk = pi.id
  inner join product_info pr on pi.product_id_fk=pr.id
  where
     date(dt.transaction_date)=date_sub(curdate(),interval 1 day) and dt.status=1 and date(cp.created_date) &lt;&gt; date(curdate()) and cp.payment_confirmed_date &lt;&gt; dt.transaction_date
  GROUP BY DateOfTransactions;
  </code></pre>