Yea, but every time RS does this, he learns a helluva lot about the problem domain. I can't speak for the rest of the forum, but I like looking at problems from a new perspective, too -- and I usually manage to learn something. Thats part of the value of these re-implementations -- just plain ol' experience! It's no inconvenience to us to help out, after all.
This is actually more or less why I want to know as well, for learning experience. I'm sure something like MySQL must have all sorts of advanced techniques for writing to the DB files, and formatting them in a way that makes it easy to retrieve information fast from disk, as well as update it fast. I know there's a concept called a lazy writer, that is one way that is used for fast retrieval if a query similar to a past query is made. I'm sure there's tons of other techniques used as well.
For more background of how the app works, here is how, before I touched it:
The app, which is a game server, loads everything from serialized files. This is probably the fastest possible way for the type of app and data. Now to change the file, the ENTIRE data set had to be written over, completely. Now this process is somewhat fast enough given there is very little overhead. The problem is, to avoid corruption, it had to halt the entire app to do the save. As the data set grows, so do the saves. If the program crashes or is stopped prematurely, then the game data has to be reverted to the last save. So this makes it important to perform saves often enough. If someone killed a hard boss, got a very rare item, and the server crashes before a save, I have a very pissed off player!
So my fix for this issue was to make it so "saves" only save what changes. So it does a save to a memory location, this save halts the game, but it is only a few milliseconds, and they happen every 5 seconds (in theory). Very unoticable. As data changes, it is saved to memory. Then another thread takes the data from the saved memory location, and does a series of updates, adds, or deletes to the database, depending on what is needed. Once this is done, then if it's been more then 5 seconds since the last save it saves again. This is rather flawless and works great. My issue is, MySQL is not really meant for the type of data I'm giving it. It's not really well structured.
So I decided I may be better off writing a custom app that is designed for accepting this type of data. I have a good idea how I will do most of it.
I just want tips on how to properly store this data to disk, so the app can keep up with the updates fast enough. Ex: is fstream fast enough, should I have an index file that points to a char location on a data file? Is there a way I can write data in the middle of a file, and push the rest of the data over? All questions I'm wondering. Should I maybe load the entire thing into memory (rather not do this, as this data grows all the time, and in a leased server environment, ram is VERY expensive) should I have 1 file per record? Lot of different ways I can do this, and I want to learn more how to do this efficiently.
You may be wondering why I don't just code this in directly into the game server app, instead of having a second app. 1) C++ / Linux will probably be faster (the game server is C#) and most importantly 2) it gives me the option to run it on a separate server so the game server can waste less time on data saving, and simply hand it off the another server. In the future I may even add clustering support, but that's a whole other ball game.