I have a query that displays the sum of quantity sold, subtotal and total sold per product. The problem is it's taking too long to execute. Am I doing this wrong? I need your help to optimize the query. Also, should I group it by sd.Product\_Id or p.Product\_Name is fine?

```
SELECT p.Product_Name   `Product Name`,
       SUM(sd.Quantity) `Quantity Sold`,
       SUM(sd.Subtotal) `Subtotal`,
       SUM(sd.Discount_Value) `Total Discount`,
       SUM(sd.Total)    `Total`
FROM Sales_Detail sd
JOIN Product p ON sd.Product_Id = p.Id
WHERE DATE(sd.Purchase_Date) BETWEEN DATE('2017-08-21')
                                 and date('2017-08-25')
GROUP BY p.Product_Name;

```