I have a few design questions that I've been thinking about for a while now. With the code base I've been programming, everything is completely query driven and it is working out well. I have set it up so some things that are frequently referenced but don't change (like a character's name) are stored in string-to-string map for the character (like a cache). An idea I've been playing with is having the character know what new data it needs and gather that data periodically and stick it in this cache instead of executing queries immediately and often. Of course this incurs the classic problems of maintaining data in two locations, so I'm not entirely sure if I should be using this cache for anything other then relatively static data that won't change much (and when it is changed, its updated in both the cache and database).
The major thing that is bothering me is that all SQL queries are executed immediately. If there were significant load on the server it seems like it would be easy to red line the database. Now, I haven't crunched the numbers to figure out how much it would take to really give PostgreSQL or MySQL a workout, but I was wondering if it might be more prudent of me to make a query scheduling system that puts the queries into a queue to be executed. There would be some significant changes to the way commands are executed as a result, but thats not a big deal at this point. The idea would be to limit the number of queries in a given cycle if there were a large amount of queries, thus alleviating some stress on the database management system.
So what do you think? Should I be concerned with the server immediately executing queries? Or are the databases advanced enough that it probably won't matter unless I have an ungodly amount of activity on the server?
I really do not want to have to re-engineer anything relating to the database and how the interface operates in the later stages, so right now the query scheduler seems like a good idea.
I should note that I'm working my best to make sure NPCs and other things don't need to query the system too much, so hopefully when few players are around the database activity will be fairly low (or completely non-existent).
The major thing that is bothering me is that all SQL queries are executed immediately. If there were significant load on the server it seems like it would be easy to red line the database. Now, I haven't crunched the numbers to figure out how much it would take to really give PostgreSQL or MySQL a workout, but I was wondering if it might be more prudent of me to make a query scheduling system that puts the queries into a queue to be executed. There would be some significant changes to the way commands are executed as a result, but thats not a big deal at this point. The idea would be to limit the number of queries in a given cycle if there were a large amount of queries, thus alleviating some stress on the database management system.
So what do you think? Should I be concerned with the server immediately executing queries? Or are the databases advanced enough that it probably won't matter unless I have an ungodly amount of activity on the server?
I really do not want to have to re-engineer anything relating to the database and how the interface operates in the later stages, so right now the query scheduler seems like a good idea.
I should note that I'm working my best to make sure NPCs and other things don't need to query the system too much, so hopefully when few players are around the database activity will be fairly low (or completely non-existent).