My MySQL query is taking around 20 minutes to execute which I feel is excessive.
SELECT
hyp_id,MAX( player_count ) AS MAXPLAYERCOUNT
, MAX( viewer_count ) AS MAXVIEWERCOUNT
, SUM( player_count ) AS TOTPLAYER
, SUM( viewer_count ) AS TOTVIEWER
FROM player_count_log
WHERE
DATE(added_time) = CURDATE()
GROUP BY hyp_id
ORDER BY hyp_id
The player_count_log
table contains over 63 million records with ~18k added every hour.
Here are screenshots of db and indexes
Best Answer
is the root of some of the evil
Do not "hide" a column
(added_time)
inside a function (DATE
) if want an index to be used.If
added_time
is aDATE
, then you can simply doIf it is a
DATETIME
orTIMESTAMP
, then doThen your
INDEX(added_time)
can be used.