DB/Search

* add more indizes to large tables for cols used in lookups
 * drop multi-column indizes on spell as they are not utilized by mysql
 * add and use fulltext indizes for names of items, spells, quests, creatures & objects
   could add more, but is it really necessary?
 * limitations
   - still need a solution for race/class/spellFamily masks cols that are used as such
   - fulltext indizes in boolean mode cant partial match the end of a word.
     reverse name cols and search and match back to front like that..? blows up db size even more though
     (+trike* : "stormstrike" => +ekirt* : "ekirtsmrots")
This commit is contained in:
Sarjuuk 2026-01-16 01:29:04 +01:00
parent a89eef5736
commit 7616ec25fc
13 changed files with 373 additions and 78 deletions

View file

@ -570,13 +570,28 @@ CREATE TABLE `aowow_creature` (
`ScriptOrAI` varchar(64) DEFAULT NULL,
`StringId` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_name` (`name_loc0`),
KEY `difficultyEntry1` (`difficultyEntry1`),
KEY `difficultyEntry2` (`difficultyEntry2`),
KEY `difficultyEntry3` (`difficultyEntry3`),
KEY `idx_loot` (`lootId`),
KEY `idx_pickpocketloot` (`pickpocketLootId`),
KEY `idx_skinloot` (`skinLootId`)
KEY `idx_skinloot` (`skinLootId`),
KEY `idx_trainer` (`trainerType`),
KEY `idx_trainerrequirement` (`trainerRequirement`),
FULLTEXT `idx_name0` (`name_loc0`),
FULLTEXT `idx_name2` (`name_loc2`),
FULLTEXT `idx_name3` (`name_loc3`),
FULLTEXT `idx_name4` (`name_loc4`),
FULLTEXT `idx_name6` (`name_loc6`),
FULLTEXT `idx_name8` (`name_loc8`),
KEY `idx_spell1` (`spell1`),
KEY `idx_spell2` (`spell2`),
KEY `idx_spell3` (`spell3`),
KEY `idx_spell4` (`spell4`),
KEY `idx_spell5` (`spell5`),
KEY `idx_spell6` (`spell6`),
KEY `idx_spell7` (`spell7`),
KEY `idx_spell8` (`spell8`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -1440,13 +1455,28 @@ CREATE TABLE `aowow_items` (
`unsheatheSoundId` smallint(5) unsigned NOT NULL DEFAULT 0,
`flagsCustom` int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_name` (`name_loc0`),
KEY `items_index` (`class`),
KEY `idx_model` (`displayId`),
KEY `idx_faction` (`requiredFaction`),
KEY `iconId` (`iconId`),
KEY `spellId1` (`spellId1`),
KEY `spellId2` (`spellId2`)
KEY `idx_spell1` (`spellId1`),
KEY `idx_spell2` (`spellId2`),
KEY `idx_spell3` (`spellId3`),
KEY `idx_spell4` (`spellId4`),
KEY `idx_spell5` (`spellId5`),
KEY `idx_trigger1` (`spellTrigger1`),
KEY `idx_trigger2` (`spellTrigger2`),
KEY `idx_trigger3` (`spellTrigger3`),
KEY `idx_trigger4` (`spellTrigger4`),
KEY `idx_trigger5` (`spellTrigger5`),
KEY `idx_reqskill` (`requiredSkill`),
FULLTEXT `idx_name0` (`name_loc0`),
FULLTEXT `idx_name2` (`name_loc2`),
FULLTEXT `idx_name3` (`name_loc3`),
FULLTEXT `idx_name4` (`name_loc4`),
FULLTEXT `idx_name6` (`name_loc6`),
FULLTEXT `idx_name8` (`name_loc8`),
KEY `idx_itemset` (`itemset`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -1631,7 +1661,16 @@ CREATE TABLE `aowow_objects` (
`ScriptOrAI` varchar(64) DEFAULT NULL,
`StringId` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_name` (`name_loc0`)
KEY `idx_onusespell` (`onUseSpell`),
KEY `idx_onsuccessspell` (`onSuccessSpell`),
KEY `idx_auraspell` (`auraSpell`),
KEY `idx_triggeredspell` (`triggeredSpell`),
FULLTEXT `idx_name0` (`name_loc0`),
FULLTEXT `idx_name2` (`name_loc2`),
FULLTEXT `idx_name3` (`name_loc3`),
FULLTEXT `idx_name4` (`name_loc4`),
FULLTEXT `idx_name6` (`name_loc6`),
FULLTEXT `idx_name8` (`name_loc8`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -2134,12 +2173,12 @@ CREATE TABLE `aowow_quests` (
`rewardFactionValue3` mediumint(9) NOT NULL DEFAULT 0,
`rewardFactionValue4` mediumint(9) NOT NULL DEFAULT 0,
`rewardFactionValue5` mediumint(9) NOT NULL DEFAULT 0,
`name_loc0` text DEFAULT NULL,
`name_loc2` text DEFAULT NULL,
`name_loc3` text DEFAULT NULL,
`name_loc4` text DEFAULT NULL,
`name_loc6` text DEFAULT NULL,
`name_loc8` text DEFAULT NULL,
`name_loc0` varchar(100) DEFAULT NULL,
`name_loc2` varchar(100) DEFAULT NULL,
`name_loc3` varchar(100) DEFAULT NULL,
`name_loc4` varchar(100) DEFAULT NULL,
`name_loc6` varchar(100) DEFAULT NULL,
`name_loc8` varchar(100) DEFAULT NULL,
`objectives_loc0` text DEFAULT NULL,
`objectives_loc2` text DEFAULT NULL,
`objectives_loc3` text DEFAULT NULL,
@ -2229,7 +2268,39 @@ CREATE TABLE `aowow_quests` (
`objectiveText4_loc6` text DEFAULT NULL,
`objectiveText4_loc8` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `nextQuestIdChain` (`nextQuestIdChain`)
KEY `nextQuestIdChain` (`nextQuestIdChain`),
FULLTEXT `idx_name0` (`name_loc0`),
FULLTEXT `idx_name2` (`name_loc2`),
FULLTEXT `idx_name3` (`name_loc3`),
FULLTEXT `idx_name4` (`name_loc4`),
FULLTEXT `idx_name6` (`name_loc6`),
FULLTEXT `idx_name8` (`name_loc8`),
KEY `idx_sourcespell` (`sourceSpellId`),
KEY `idx_rewardspell` (`rewardSpell`),
KEY `idx_rewardcastspell` (`rewardSpellCast`),
KEY `idx_classmask` (`reqRaceMask`),
KEY `idx_racemask` (`reqClassMask`),
KEY `idx_questsort` (`questSortId`),
KEY `idx_rewarditem1` (`rewardChoiceItemId1`),
KEY `idx_rewarditem2` (`rewardChoiceItemId2`),
KEY `idx_rewarditem3` (`rewardChoiceItemId3`),
KEY `idx_rewarditem4` (`rewardChoiceItemId4`),
KEY `idx_rewarditem5` (`rewardChoiceItemId5`),
KEY `idx_rewarditem6` (`rewardChoiceItemId6`),
KEY `idx_rewardfaction1` (`rewardFactionId1`),
KEY `idx_rewardfaction2` (`rewardFactionId2`),
KEY `idx_rewardfaction3` (`rewardFactionId3`),
KEY `idx_rewardfaction4` (`rewardFactionId4`),
KEY `idx_rewardfaction5` (`rewardFactionId5`),
KEY `idx_choiceitem1` (`rewardItemId1`),
KEY `idx_choiceitem2` (`rewardItemId2`),
KEY `idx_choiceitem3` (`rewardItemId3`),
KEY `idx_choiceitem4` (`rewardItemId4`),
KEY `idx_requirement1` (`reqNpcOrGo1`),
KEY `idx_requirement2` (`reqNpcOrGo2`),
KEY `idx_requirement3` (`reqNpcOrGo3`),
KEY `idx_requirement4` (`reqNpcOrGo4`),
KEY `idx_event` (`eventId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -2787,8 +2858,6 @@ CREATE TABLE `aowow_spell` (
PRIMARY KEY (`id`),
KEY `category` (`typeCat`),
KEY `spell` (`id`) USING BTREE,
KEY `effects` (`effect1Id`,`effect2Id`,`effect3Id`),
KEY `items` (`effect1CreateItemId`,`effect2CreateItemId`,`effect3CreateItemId`),
KEY `iconId` (`iconId`),
KEY `reagent1` (`reagent1`),
KEY `reagent2` (`reagent2`),
@ -2806,7 +2875,22 @@ CREATE TABLE `aowow_spell` (
KEY `effect3Id` (`effect3Id`),
KEY `effect1AuraId` (`effect1AuraId`),
KEY `effect2AuraId` (`effect2AuraId`),
KEY `effect3AuraId` (`effect3AuraId`)
KEY `effect3AuraId` (`effect3AuraId`),
KEY `idx_skill1` (`skillLine1`),
KEY `idx_skill2` (`skillLine2OrMask`),
FULLTEXT `idx_name0` (`name_loc0`),
FULLTEXT `idx_name2` (`name_loc2`),
FULLTEXT `idx_name3` (`name_loc3`),
FULLTEXT `idx_name4` (`name_loc4`),
FULLTEXT `idx_name6` (`name_loc6`),
FULLTEXT `idx_name8` (`name_loc8`),
KEY `idx_spellfamily` (`spellFamilyId`),
KEY `idx_miscvalue1` (`effect1MiscValue`),
KEY `idx_miscvalue2` (`effect2MiscValue`),
KEY `idx_miscvalue3` (`effect3MiscValue`),
KEY `idx_triggerspell1` (`effect1TriggerSpell`),
KEY `idx_triggerspell2` (`effect2TriggerSpell`),
KEY `idx_triggerspell3` (`effect3TriggerSpell`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

View file

@ -71,7 +71,7 @@ UNLOCK TABLES;
LOCK TABLES `aowow_dbversion` WRITE;
/*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */;
INSERT INTO `aowow_dbversion` VALUES (1768517244,0,NULL,NULL);
INSERT INTO `aowow_dbversion` VALUES (1768556689,0,NULL,NULL);
/*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */;
UNLOCK TABLES;

View file

@ -0,0 +1,120 @@
ALTER TABLE `aowow_spell`
DROP INDEX `items`,
DROP INDEX `effects`,
ADD INDEX `idx_skill1` (`skillLine1`),
ADD INDEX `idx_skill2` (`skillLine2OrMask`),
ADD FULLTEXT `idx_name0` (`name_loc0`),
ADD FULLTEXT `idx_name2` (`name_loc2`),
ADD FULLTEXT `idx_name3` (`name_loc3`),
ADD FULLTEXT `idx_name4` (`name_loc4`),
ADD FULLTEXT `idx_name6` (`name_loc6`),
ADD FULLTEXT `idx_name8` (`name_loc8`),
ADD INDEX `idx_spellfamily` (`spellFamilyId`),
ADD INDEX `idx_miscvalue1` (`effect1MiscValue`),
ADD INDEX `idx_miscvalue2` (`effect2MiscValue`),
ADD INDEX `idx_miscvalue3` (`effect3MiscValue`),
ADD INDEX `idx_triggerspell1` (`effect1TriggerSpell`),
ADD INDEX `idx_triggerspell2` (`effect2TriggerSpell`),
ADD INDEX `idx_triggerspell3` (`effect3TriggerSpell`)
;
ALTER TABLE `aowow_quests`
MODIFY COLUMN `name_loc0` varchar(100) DEFAULT NULL,
MODIFY COLUMN `name_loc2` varchar(100) DEFAULT NULL,
MODIFY COLUMN `name_loc3` varchar(100) DEFAULT NULL,
MODIFY COLUMN `name_loc4` varchar(100) DEFAULT NULL,
MODIFY COLUMN `name_loc6` varchar(100) DEFAULT NULL,
MODIFY COLUMN `name_loc8` varchar(100) DEFAULT NULL,
ADD FULLTEXT `idx_name0` (`name_loc0`),
ADD FULLTEXT `idx_name2` (`name_loc2`),
ADD FULLTEXT `idx_name3` (`name_loc3`),
ADD FULLTEXT `idx_name4` (`name_loc4`),
ADD FULLTEXT `idx_name6` (`name_loc6`),
ADD FULLTEXT `idx_name8` (`name_loc8`),
ADD INDEX `idx_sourcespell` (`sourceSpellId`),
ADD INDEX `idx_rewardspell` (`rewardSpell`),
ADD INDEX `idx_rewardcastspell` (`rewardSpellCast`),
ADD INDEX `idx_classmask` (`reqRaceMask`),
ADD INDEX `idx_racemask` (`reqClassMask`),
ADD INDEX `idx_questsort` (`questSortId`),
ADD INDEX `idx_rewarditem1` (`rewardChoiceItemId1`),
ADD INDEX `idx_rewarditem2` (`rewardChoiceItemId2`),
ADD INDEX `idx_rewarditem3` (`rewardChoiceItemId3`),
ADD INDEX `idx_rewarditem4` (`rewardChoiceItemId4`),
ADD INDEX `idx_rewarditem5` (`rewardChoiceItemId5`),
ADD INDEX `idx_rewarditem6` (`rewardChoiceItemId6`),
ADD INDEX `idx_rewardfaction1` (`rewardFactionId1`),
ADD INDEX `idx_rewardfaction2` (`rewardFactionId2`),
ADD INDEX `idx_rewardfaction3` (`rewardFactionId3`),
ADD INDEX `idx_rewardfaction4` (`rewardFactionId4`),
ADD INDEX `idx_rewardfaction5` (`rewardFactionId5`),
ADD INDEX `idx_choiceitem1` (`rewardItemId1`),
ADD INDEX `idx_choiceitem2` (`rewardItemId2`),
ADD INDEX `idx_choiceitem3` (`rewardItemId3`),
ADD INDEX `idx_choiceitem4` (`rewardItemId4`),
ADD INDEX `idx_requirement1` (`reqNpcOrGo1`),
ADD INDEX `idx_requirement2` (`reqNpcOrGo2`),
ADD INDEX `idx_requirement3` (`reqNpcOrGo3`),
ADD INDEX `idx_requirement4` (`reqNpcOrGo4`),
ADD INDEX `idx_event` (`eventId`)
;
ALTER TABLE `aowow_creature`
DROP INDEX `idx_name`,
ADD INDEX `idx_trainer` (`trainerType`),
ADD INDEX `idx_trainerrequirement` (`trainerRequirement`),
ADD FULLTEXT `idx_name0` (`name_loc0`),
ADD FULLTEXT `idx_name2` (`name_loc2`),
ADD FULLTEXT `idx_name3` (`name_loc3`),
ADD FULLTEXT `idx_name4` (`name_loc4`),
ADD FULLTEXT `idx_name6` (`name_loc6`),
ADD FULLTEXT `idx_name8` (`name_loc8`),
ADD INDEX `idx_spell1` (`spell1`),
ADD INDEX `idx_spell2` (`spell2`),
ADD INDEX `idx_spell3` (`spell3`),
ADD INDEX `idx_spell4` (`spell4`),
ADD INDEX `idx_spell5` (`spell5`),
ADD INDEX `idx_spell6` (`spell6`),
ADD INDEX `idx_spell7` (`spell7`),
ADD INDEX `idx_spell8` (`spell8`)
;
ALTER TABLE `aowow_items`
DROP INDEX `spellId1`,
DROP INDEX `spellId2`,
DROP INDEX `idx_name`,
ADD INDEX `idx_spell1` (`spellId1`),
ADD INDEX `idx_spell2` (`spellId2`),
ADD INDEX `idx_spell3` (`spellId3`),
ADD INDEX `idx_spell4` (`spellId4`),
ADD INDEX `idx_spell5` (`spellId5`),
ADD INDEX `idx_trigger1` (`spellTrigger1`),
ADD INDEX `idx_trigger2` (`spellTrigger2`),
ADD INDEX `idx_trigger3` (`spellTrigger3`),
ADD INDEX `idx_trigger4` (`spellTrigger4`),
ADD INDEX `idx_trigger5` (`spellTrigger5`),
ADD INDEX `idx_reqskill` (`requiredSkill`),
ADD FULLTEXT `idx_name0` (`name_loc0`),
ADD FULLTEXT `idx_name2` (`name_loc2`),
ADD FULLTEXT `idx_name3` (`name_loc3`),
ADD FULLTEXT `idx_name4` (`name_loc4`),
ADD FULLTEXT `idx_name6` (`name_loc6`),
ADD FULLTEXT `idx_name8` (`name_loc8`),
ADD INDEX `idx_itemset` (`itemset`)
;
ALTER TABLE `aowow_objects`
DROP INDEX `idx_name`,
ADD INDEX `idx_onusespell` (`onUseSpell`),
ADD INDEX `idx_onsuccessspell` (`onSuccessSpell`),
ADD INDEX `idx_auraspell` (`auraSpell`),
ADD INDEX `idx_triggeredspell` (`triggeredSpell`),
ADD FULLTEXT `idx_name0` (`name_loc0`),
ADD FULLTEXT `idx_name2` (`name_loc2`),
ADD FULLTEXT `idx_name3` (`name_loc3`),
ADD FULLTEXT `idx_name4` (`name_loc4`),
ADD FULLTEXT `idx_name6` (`name_loc6`),
ADD FULLTEXT `idx_name8` (`name_loc8`)
;
UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' achievementcriteria');

View file

@ -60,10 +60,12 @@ class DBC
'S' => 'V', // S - string block index, 4 bytes - localized; autofill
'f' => 'f', // f - float, 4 bytes (rounded to 4 digits after comma)
'i' => 'l', // i - signed int, 4 bytes
'I' => 'l', // I - signed int, 4 bytes, sql index
'u' => 'V', // u - unsigned int, 4 bytes
'U' => 'V', // U - unsigned int, 4 bytes, sql index
'b' => 'C', // b - unsigned char, 1 byte
'd' => 'x4', // d - ordered by this field, not included in array
'n' => 'V' // n - int, 4 bytes, ordered by this field
'n' => 'V' // n - unsigned int, 4 bytes, sql primary key
);
public const DEFAULT_WOW_BUILD = '12340';
@ -284,8 +286,9 @@ class DBC
if ($this->error)
return;
$pKey = '';
$query = 'CREATE '.($this->tempTable ? 'TEMPORARY' : '').' TABLE `'.$this->tableName.'` (';
$pKey = '';
$query = 'CREATE '.($this->tempTable ? 'TEMPORARY' : '').' TABLE `'.$this->tableName.'` (';
$indizes = [];
if ($this->isGameTable)
{
@ -312,10 +315,14 @@ class DBC
case 'b':
$query .= '`'.$name.'` TINYINT UNSIGNED NOT NULL, ';
break;
case 'I':
$indizes[] = $name;
case 'i':
case 'n':
$query .= '`'.$name.'` INT SIGNED NOT NULL, ';
break;
case 'U':
$indizes[] = $name;
case 'u':
$query .= '`'.$name.'` INT UNSIGNED NOT NULL, ';
break;
@ -327,6 +334,9 @@ class DBC
$pKey = $name;
}
foreach ($indizes as $i)
$query .= 'KEY `idx_'.$i.'` (`'.$i.'`), ';
if ($pKey)
$query .= 'PRIMARY KEY (`'.$pKey.'`) ';
else

View file

@ -39,8 +39,8 @@ UNUSED3 = x
[achievement_criteria]
id = n
refAchievementId = i
type = i
value1 = i
type = I
value1 = I
value2 = i
value3 = i
value4 = i