[11045] Rewrite internals of DB layer. Simplify code and use less locking. Spawn and use separate connections for sync and async DB requests. Implement database connection pool for SELECT queries. Up to maximum 16 connections supported. Disable 'autocommit' mode for MySQL.

UPDATE YOUR CONFIGS!

Defaults:
LoginDatabaseConnections = 1
WorldDatabaseConnections = 1
CharacterDatabaseConnections = 1

If you are not using <mtmaps> patch do not change the default settings - this is useless. You can try following option in your MySQL config to squeeze even more performance from your DB:

[mysqld]
transaction-isolation = READ-COMMITTED

Great thanks to Undergarun, kero99 and selector for making tests and providing very useful feedback and DB statistics! Have fun :)

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
Ambal 2011-01-19 22:04:54 +02:00
parent 9bc37afa28
commit 631ce36680
19 changed files with 655 additions and 547 deletions

View file

@ -89,7 +89,6 @@ World::World()
m_startTime=m_gameTime;
m_maxActiveSessionCount = 0;
m_maxQueuedSessionCount = 0;
m_resultQueue = NULL;
m_NextDailyQuestReset = 0;
m_NextWeeklyQuestReset = 0;
m_scheduledScripts = 0;
@ -133,8 +132,6 @@ World::~World()
VMAP::VMapFactory::clear();
if(m_resultQueue) delete m_resultQueue;
//TODO free addSessQueue
}
@ -1938,13 +1935,14 @@ void World::ProcessCliCommands()
void World::InitResultQueue()
{
m_resultQueue = new SqlResultQueue;
CharacterDatabase.SetResultQueue(m_resultQueue);
}
void World::UpdateResultQueue()
{
m_resultQueue->Update();
//process async result queues
CharacterDatabase.ProcessResultQueue();
WorldDatabase.ProcessResultQueue();
LoginDatabase.ProcessResultQueue();
}
void World::UpdateRealmCharCount(uint32 accountId)
@ -1960,8 +1958,11 @@ void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId
Field *fields = resultCharCount->Fetch();
uint32 charCount = fields[0].GetUInt32();
delete resultCharCount;
LoginDatabase.BeginTransaction();
LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%u' AND realmid = '%u'", accountId, realmID);
LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID);
LoginDatabase.CommitTransaction();
}
}