khalidahmedshalabi/SAMPBulletproof

Lag issue related to SQL queries

Closed this issue · 0 comments

Referred to #17. Here are some SQL queries that make the server hangs for a couple of seconds. I'm not quite sure if it's just a bad host though. Note: there are 115 registered players in the database.

format(iString, sizeof(iString), "UPDATE Players SET Level = %d WHERE Name = '%s' AND Level != %d", LEVEL, DB_Escape(Player[GiveID][Name]), LEVEL);
    db_free_result(db_query(sqliteconnection, iString));
foreach(new i : Player) 
    {
        // ...
        db_free_result(db_query(sqliteconnection, sprintf("UPDATE Players SET NetCheck = 1, TempTag = '%s' WHERE Name = '%s'", DB_Escape(Player[i][TempTag]), DB_Escape(Player[i][Name]))));

        // ...
    }
// Update players table with new IP address for auto login if they reconnect.
    format(iString, sizeof(iString), "UPDATE `Players` SET `IP` = '%s' WHERE `Name` = '%s' AND IP != '%s'", IP, Player[playerid][Name], IP);
    db_free_result(db_query(sqliteconnection, iString));

Reminder: script something that deletes inactive accounts from time to time (based on last login date and time) if no other solutions are found.