Posts: 219
Threads: 19
Joined: Jan 2013
Reputation:
0
hey guys - just had a quick question.
Seen a lot lately on people switching to mysql saving. Having used a lot of mysql in web development i know exactly how it all works etc so that's not a problem.
What I'm wondering in whether or not its really worth me switching over to mysql. What are the real benefits? In terms of efficiency most older comps can run an sa-mp server without even blinking so I'm not worried about speed and efficiency so much these days.
I'm thinking the one huge benefit would be real-time stats tracking via a website and website integration for username and password etc.
Anything I'm missing there or is that the one big benefit?
Posts: 1,905
Threads: 63
Joined: Oct 2011
Reputation:
0
Well, the pros and cons of MySQL are spammed all across these forums but anyways.
If you use flat files and there are a lot of players online with a lot of data to write, you might catch the server at a bad time. Pawn is single threaded, meaning every instruction must be finished before moving on to the next.
Let's say you have so much data to write, that it takes 500ms (it's possible). For 500ms, nothing will be updated for the clients (basically players won't see each other move and damage won't be dealt with). The server will hang for that 500ms (which is an eternity for PCs) while it's writing all that data.
However, if you use threaded MySQL queries, all of data writing/reading is processed on a separate thread from the main server thread, meaning you could be writing 1,000,000 values, and the server will still send updates to clients while the MySQL thread is processing your query.
One thing to keep in mind though is that there are a lot of file-based libraries that work well, and modern PCs can handle quite a bit.
Just search these forums, there is tons of more reading material on the subject.
Posts: 7,801
Threads: 187
Joined: Feb 2010
Reputation:
0
Honestly, IMHO, the main two benefits of using MySQL is the ability to have threaded queries (as outlined by VincentDunn) and of course the ease-of-expansion for use with non-SA:MP applications.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
MySQL (or SQLite) is great for statistics. You can for example find the user with the most money, the highest score, how many admins there are, etc. If you want to do this in a file based system you would have to loop through all player files (impossible), or you'd have to create a separate file that saves the high score of each player. That file should then regularly be checked for integrity (impracticle).
Posts: 219
Threads: 19
Joined: Jan 2013
Reputation:
0
Ok I see what you guys are saying and can see the benefits. I've streamlined the system I use to never call a function during a file save operation which has cut the lag to zero pretty much on that side of things.
Now anyone who knows the vehicle system I designed years ago can tell ya there's a crap load of info being saved pretty regularly. Probs about 20-30 variables per vehicle every time the saving routine is called and that's where I can see a huge benefit! I guess my next question may seem a tad redundant and I recon I know the answer but just to check, whether or not the saving routine interacts with a player directly shouldn't effect the time for the operation to complete or will a players ping effect this? Say for example I wanted to save money and used getplayermoney. If the player had a horrible ping that shouldn't increase time to completion due to the server having that info already correct?
Just to clarify, I've long since swit he'd to simply loadin info into a player based array to prevent the need to call functions when saving but I'm wondering if it really makes a huge difference?
Posts: 7,801
Threads: 187
Joined: Feb 2010
Reputation:
0
Well when I said that I really just mean for use with things like UCP's. I don't know PHP, but I'm assuming that loading data through MySQL is easier than having to deal with files, especially if they aren't on the same server.