This select keeps timing out:
SELECT COUNT(DISTINCT `invoices`)
FROM `data`
WHERE date BETWEEN '2013-07-01' AND '2014-06-30'
GROUP BY `store`
I have made indexes on invoices, date, store and invoices, store, date. Any help is appreciated.
try
SELECT `store`, COUNT(*) FROM
(SELECT `store`, `invoices`
FROM `data`
WHERE date BETWEEN '2013-07-01' AND '2014-06-30'
GROUP BY `store`, `invoices`
) tbl
GROUP BY `store`
Here's a fiddle, without the date
column and check...
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments