Minor Lag Caused By db_query (SQLite)
#1

I noticed some lag which occurred in a command, and traced it to the saving proportion of my script. The issue is 34 queries (run at the same time with other queries used to save player data and information; amount also dependent on how many vehicles a player has that I'm saving information for).

pawn Код:
new string[128];
for(new l = 0; l < 17; l ++)
{
    format(string, sizeof(string), "UPDATE `VEHICLES` SET `MOD%d` = '%d' WHERE `ID` = '%d'", l, PlayerVehicleInformation[playerid][i][Mod][l], <ID>);
    db_query(database, string);
}
The proportion of code shown above was previously something similar (but not exact) to:

pawn Код:
new string[512];
format(string, sizeof(string), "UPDATE `VEHICLES` SET `MOD1`, `MOD2, `MOD3`, `MOD4` WHERE `ID` = '%d", mod[0], mod[1], mod[2], mod[3], etc);
However I decided to use a loop instead as it would be shorter. When retrieving information, these loops (and db_get_field_assoc()) do not cause an issue. Again, the lag is minor, but is there something I should be doing better to prevent db_query from causing this issue (aside from what I initially had)? Thanks.
Reply


Messages In This Thread
Lag Caused By db_query (SQLite) - by DrakeX - 10.06.2014, 12:35
Re: Minor Lag Caused By db_query (SQLite) - by DrakeX - 11.06.2014, 16:00
Re: Minor Lag Caused By db_query (SQLite) - by DanLore - 11.06.2014, 17:47

Forum Jump:


Users browsing this thread: 4 Guest(s)