problem description
i have data table multiplayergame
where there multiple records each userid
detailing activities during multiplayer game, , date dateid
game occurred on.
question
how can query games each user occur within the first month of first game ? i.e., grab rows user occur within 30 days of first record first multiplayer game?
this slow if have lot of users, work. subquery gets list of userid's , first game's dateid, selects games dateid between date , next 30 days (for each user). if added first game date user table or used user created_at date speed lot because of full use of indexes.
select * multiplayergame m1 join (select min(m.dateid) first_game, m.userid multiplayergame m group m.userid) der on der.userid=m1.userid , m1.dateid between der.first_game , der.first_game + interval 30 day
Comments
Post a Comment