Jump to content

[patch][6908] faster setting online=0 at startup

Guest balrok

Recommended Posts

who has written the patch?


what should this patch do?

speed up server starting

for what revision?

rev @ 13.12.

i compared with phpmyadmin:

0 row(s) affected. ( Query took 61.5304 sec )

UPDATE characters SET online =0

0 row(s) affected. ( Query took 0.0012 sec )

UPDATE characters SET online =0 WHERE online <>0


when i run every update several time the first one goes down to 1.x seconds

and the second command goes down to 0.000x seconds

mysql version:5.0.51a

so i made this fix

diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp
index 1b69292..f5ef907 100644
--- a/src/mangosd/Master.cpp
+++ b/src/mangosd/Master.cpp
@@ -459,7 +459,7 @@ void Master::clearOnlineAccounts()
        "AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID);

-    CharacterDatabase.Execute("UPDATE characters SET online = 0");
+    CharacterDatabase.Execute("UPDATE characters SET online = 0 WHERE online<>0");

/// Handle termination signals

after that, i searched the code for other similar queries with

grep -i "execute.*UPDATE" game/WorldSocket.cpp | grep -vi "WHERE"

and only found those queries:

Level2.cpp:3140:        WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '0'");
Level3.cpp:4567:    CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u'",atLogin);

Link to comment
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use