Hi!
Is there any way to select random object from BigDB table?
I want my game to select level randomly, and I also have level editor, so amount of levels will grow in time and I can't use "loadRange" and select random index with server code.
First, i wanted to implement "played" property to count times the level was played, then sort this in ascending way and select the lowest so that gameplay would distribute evenly, but then I understood that new levels having "zero" played times will always be on top and being played more and more by the same players untill they get common "played" value, and old levels would become unreachable. So this is not the way either.
The best way i see this is selecting random index with some limitation options. In SQL it would be smth like this:
SELECT * FROM my_levels WHERE level_id not in ("levels", "i have", "already", "played", "today") ORDER BY rand() LIMIT 0,1
Any advice?
UPD:
I've suddenly got an idea to change "played" counter to "last played" datetime value, so level would be played only once and then "timestamped". Is this the best decision, at least for now?