我有一個相當大的遊戲,30-40-50人在一天中的大多數點。我們將有關坦克的信息存儲到mysql數據庫中,當他們拍攝或失去健康時,我們將其轉儲到數據庫。由於這個原因,我們看到一個非常高的處理器和HDD Spike,結果是遊戲滯後。Mysql高UPDATE SELECT導致滯後
犯規聲明:
UPDATE MapData
SET Health = @1, X = @2, Y = @3,TotalPoints = @4
, RankPoints = @5
WHERE MapID = @6
AND TankID = @7
AND Color = @8
我想知道,如果有一些事情我可以做,以幫助滯後的。
CREATE TABLE `mapdata` (
`MapID` int(11) NOT NULL,
`TankID` int(11) NOT NULL,
`Color` tinyint(4) NOT NULL,
`X` int(11) DEFAULT ''-1'',
`Y` int(11) DEFAULT ''-1'',
`Rank` tinyint(4) NOT NULL DEFAULT ''0'',
`Health` int(11) NOT NULL DEFAULT ''1000'',
`Armors` tinyint(4) NOT NULL DEFAULT ''0'',
`Duals` tinyint(4) NOT NULL DEFAULT ''0'',
`Missiles` tinyint(4) NOT NULL DEFAULT ''0'',
`Homings` tinyint(4) NOT NULL DEFAULT ''0'',
`Radars` tinyint(4) NOT NULL DEFAULT ''0'',
`Beacons` tinyint(4) NOT NULL DEFAULT ''0'',
`HasRankKill` bit(1) NOT NULL DEFAULT b''0'',
`TotalPP` bigint(20) NOT NULL DEFAULT ''0'',
`RankPP` bigint(20) NOT NULL DEFAULT ''0'',
`KillCount` int(11) NOT NULL DEFAULT ''0'',
`DeathCount` int(11) NOT NULL DEFAULT ''0'',
`TimePlayed` time NOT NULL DEFAULT ''00:00:00'',
`EnabledEquipment` tinyint(4) NOT NULL DEFAULT ''0'',
`Prestige` tinyint(4) NOT NULL DEFAULT ''0'',
PRIMARY KEY (`MapID`,`TankID`,`Color`),
KEY `MapID` (`MapID`),
KEY `TankID` (`TankID`),
KEY `idx_mapdata` (`MapID`,`Color`,`TankID`),
CONSTRAINT `mapdata_ibfk_1` FOREIGN KEY (`MapID`) REFERENCES `maps` (`ID`) ON DELETE CASCADE,
CONSTRAINT `mapdata_ibfk_2` FOREIGN KEY (`TankID`) REFERENCES `tank` (`ID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
有什麼方法,我能堅持在表中存儲,而不是在HDD上,並將它傾倒每隔一段時間回盤?
['EXPLAIN'](http://dev.mysql.com/doc/refman/5.1/en/explain.html)的輸出結果是什麼? – outis