I have a table Products with products and table Sales with all sale operations that was done on these products. These tables are connected by Sales.PRODUCT_ID column.
I would like to get 10 most often sold products today and what I did is this:
SELECT product.* , COUNT( sale.ID ) SUMSELL
FROM Products product
LEFT JOIN
Sales sale
ON
sale.ANKIETA_ID = product.ID AND
sale.DATE >= DATE_SUB( NOW( ) , INTERVAL 1 DAY )
GROUP BY product.ID
ORDER BY SUMSELL DESC
LIMIT 0 , 10
But performance of it is very slow. What can I do to increase performance of this particular query?