0
I’m doing a date search on mysql, but it gets very slow (more than half a second).
Is there any way to optimize this search to get faster?
Ex: of consultation:
SELECT dt.data,count(d.id) AS downloads, DATE_FORMAT(d.data, '%d/%m/%Y') as dataformat, DATE_FORMAT(d.data, '%d/%m') as dia, DATE_FORMAT(d.data, '%a') as semana FROM sig_datas dt
LEFT JOIN sig_downloads_historicodownload d ON DATE_FORMAT(dt.data, '%d/%m/%Y') = DATE_FORMAT(d.data, '%d/%m/%Y')
WHERE dt.data >= '2020-05-22'
AND dt.data <= '2020-05-25'
GROUP BY dataformat
ORDER BY dt.data ASC
Why do you format dates in the merge criteria? Iofc in GROUP BY?
– anonimo
to display the total number of downloads per day
– Leandro Marzullo
But his field
dt.data
is no longer the typedate
? Or is it likedatetime
ortimestamp
?– anonimo