I wasn't sure where to post this so hopefully here is good.
Working on a browser game with a friend powered by a php backend. It's fairly simple but I can't decide when to update certain parts of the server.
For example the player can request to build something which, if allowed, puts an entry into their build queue and when its complete the entry gets moved out the queue and into a finished buildings table in the db.
Moving things out of the queue table and into the finished table is one such task - I could scan the table for a specific players jobs every time that player requests an update of their building status OR I could have a Tick() method or something that scans the entire table for all players at once and moves completed buildings into the finished table.
In the first case stuff is only done exactly when it's needed and if no players are online then nothing is done at all- however if 200 players are online all staring at their city then 200 db calls are being done every 2sec for updates.
In the 2nd case I'm always going to be scanning every 2 secs the entire table - much bigger dataset.. but alot of the work can be done with one single big db query rather than multiple small ones.
I have no idea which is more efficient ?
Obviously there are LOTS of task to perform (building, research, unit production, unit movements) that all basically have the same query.
Thanks for your time and advice!