MySQL Lag - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Lag (
/showthread.php?tid=463945)
MySQL Lag -
NeroX98 - 14.09.2013
Hi Guys.
I have the MySQL R7 plugin with cache... The MySQL Plugin is making lag on the server and also sometimes they can't login/register because the server is too busy working with mysql functions... MySQL saves every 5 minutes. I dont have mysql_store_result and mysql_free_result because on the official thread says that i don't need in R7 plugin. What do i miss to put or is a plugin bug ?
Example of code...
pawn Код:
forward LoadKukji();
public LoadKukji()
{
for(new i = 0; i < MAX_HOUSES; i++)
{
new szDestination[100];
mysql_format(handle,szDestination,sizeof(szDestination), "SELECT * FROM `Kukji` WHERE KukjaID = '%d'",i);
mysql_function_query(handle,szDestination,true,"VcituvanjeKukji","i",i);
}
return 1;
}
forward VcituvanjeKukji(kukjaid);
public VcituvanjeKukji(kukjaid)
{
new rows, fields;
cache_get_data(rows, fields);
if(!rows) // Pogresen pass
{
return 1;
}
new podatok[64];
cache_get_row(0, 1, podatok);
HouseInfo[kukjaid][hOwned] = strval(podatok);
cache_get_field_content(0, "hOwner", podatok);
strmid(HouseInfo[kukjaid][hOwner], podatok, 0, strlen(podatok), 64);
// ETC..ETC..ETC..ETC..ETC..ETC
return 1;
}
Re: MySQL Lag -
Konstantinos - 14.09.2013
It's better to "SELECT * FROM `Kukji`" and then loop through the houses. So, it will be executed only once instead of n times (n = MAX_HOUSES).
By the way, saving every 5 minutes for houses is pointless. If someone buys a house, insert it to the database. If someone sells a house (not owning it anymore), delete it from the database and so on.
Re: MySQL Lag -
NeroX98 - 14.09.2013
Okay, so i've changed to update houses, apartments etc on payday and fixed the loops
REP +