dini2 vs SQLite? (Speed)
#21

Quote:
Originally Posted by iKarim
Посмотреть сообщение
Are you sure you're on the right forum? Most of the people here know how to setup a MySQL server except those few have 2 digit IQ --you may be one of them-- and I doubt your capability of writing a library judging by your recent posts.
Ok. Thanks.
Reply
#22

Also, if people want to use your include (which would use MySQL), and they don't know how to use it, then they should use something else.
You can't be bothered with the fact someone might not know how to use it, you can't please everyone.
If they don't know how to use it, it's their problem. They can always learn though.

Connecting to MySQL isn't the worst problem.
They still need to setup MySQL on their pc's and create the tables, that's the hardest part.

And you cannot treat MySQL as if you are using an INI file system.

Usually with files, you overwrite the entire file when one value changes.
So it's convenient to write one big save-function to save everything at once whenever one value changes.

You could do the same with MySQL, create one huge query to update everything, but it's a waste of resources.
Usually, with MySQL, when one value changes, you use a small query to update only that single value, not everything at once (where 99% of all values don't change).
I've seen scripts that use one query which updates over a hundred values and they execute that query whenever something changes like money.
But you clearly see in that query that they're also updating the sex of their character, skin, email, name, password and alot of other stuff which rarely changes.
Using one huge query also generates new challenges like keeping your query bug-free.
Instead, use small functions to do just one thing, like giving money to the player.
Код:
// This function is used to give (or take) money to/from the player
Player_GiveMoney(playerid, amount)
{
	// Setup local variables
	new query[128];

	// Add the given money to the player's account
	APlayerData[playerid][Money] = APlayerData[playerid][Money] + amount;

	// Also update the client immediately instead of waiting for the global timer to update it
	ResetPlayerMoney(playerid);
	GivePlayerMoney(playerid, APlayerData[playerid][Money]);

	// Update money for this player in the player's account in MySQL
	mysql_format(SQL_db, query, sizeof(query), "UPDATE playerdata SET Money = '%i' WHERE UserID = '%i'", APlayerData[playerid][Money], APlayerData[playerid][UserID]);
	mysql_tquery(SQL_db, query, "", "");

	return 1;
}
Functions like these use very little memory, do just one thing and it doesn't generate unneccessary load on your MySQL database.
Because MySQL has to process that entire query, split it up into different sections and variables, needs to find those columns and rows in the database, do some checks on them like comparing if the given value can fit inside the database field (can't store a float in an integer field) and alot more. Also MySQL will check if that value isn't stored already (it won't overwrite the field if the contents are identical due to unneccessary harddrive operations).
The longer the query, the longer it takes for MySQL to process it.
Why should MySQL have to handle a 100-value query where only one value needs changing?
99% of the time needed to process that query is wasted processor power.

Using a single if-statement to choose between INI and MySQL saving won't do the trick.
To do it properly, you'll be writing 2 separate scripts.
One optimized for INI, the other for MySQL.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)