MySQL Optimization for Server -
SkyFlare - 31.01.2019
So i am getting a "hang" when i exit the server in the server.exe
heres what kind of functions I have ongamemodeinit, that i believe are slowing me down
I aim to ask for some points in the right direction to enhance my coding, better my mysql knowledge and improve this script method im using
ALSO: is there anyway to replace for( with foreach(? ive been trying for a while now, because ive had problems without foreach with playerids etc in the past and have had to recode to foreach
pawn Code:
LoadMySQLTable()
{
printf("===================================================================");
printf("|+|+|+|+|+| Loading mysqltable From the MySQL Database |+|+|+|+|+|");
printf("===================================================================");
new rows;
mysql_query(g_SQL, "SELECT * FROM `mysqltable` ORDER BY `id` ASC");
if(cache_get_row_count(rows))
{
for(new r = 0; r < rows && r < MAX_MYSQLTABLEROWS; r++)
{
}
}
printf("%i MYSQLTABLE rows loaded from the Database!", rows);
return 1;
}
Re: MySQL Optimization for Server -
SkyFlare - 31.01.2019
Quote:
Originally Posted by ******
Profile it and read "use the index Luke".
|
thank you, will read through this, found the website and am beginning to read it
awesome!
Re: MySQL Optimization for Server -
Calisthenics - 31.01.2019
Quote:
Originally Posted by SkyFlare
So i am getting a "hang" when i exit the server in the server.exe
|
https://sampwiki.blast.hk/wiki/MySQL#mysql_close
Quote:
mysql_close will always wait until all queued queries are executed, thus halting the server.
|
Update data when they change, do not update EVERYTHING when the server closes. Less queries and less data to update at that time will reduce the "hang" time.
Re: MySQL Optimization for Server -
SkyFlare - 31.01.2019
Quote:
Originally Posted by Calisthenics
Update data when they change, do not update EVERYTHING when the server closes. Less queries and less data to update at that time will reduce the "hang" time.
|
I do this anyway.... :P thanks though....
the "hang" im getting is when the server closes, but when the server closes, there shouldnt be much to append to MySQL as it changes as im updating.
I just read Data from MYSQL to display it currently and create the objects/data associated to the values, it doesnt get changed.
like Loading Default Gang HQ entrances,
faction/family IDS and all the custom rank names, car colors etc.
then i setup pickups for the xyz pos saved in mysql, all that stuff, only data that really changes is the player data.
but the GM ive started off of was pBlueG's recent
login_system-cache.pwn
And it was fine closing when i first got the script haha
Re: MySQL Optimization for Server -
Calisthenics - 31.01.2019
https://sampwiki.blast.hk/wiki/MySQL#my...cessed_queries
Check how many queries are in queque when the server closes. Set log level to ERROR | WARNING | INFO and check how long it takes to execute these queries. Using ALL log level will be slower.