Setup/SQL

* change sql batching to account for non continuous indizes in world tables
This commit is contained in:
Sarjuuk
2023-03-10 17:43:39 +01:00
parent f05fe60030
commit ca26955ac2
4 changed files with 28 additions and 48 deletions

View File

@@ -120,15 +120,14 @@ SqlGen::register(new class extends SetupScript
creature_template_resistance ctr5 ON ct.entry = ctr5.CreatureID AND ctr5.School = 5 creature_template_resistance ctr5 ON ct.entry = ctr5.CreatureID AND ctr5.School = 5
LEFT JOIN LEFT JOIN
creature_template_resistance ctr6 ON ct.entry = ctr6.CreatureID AND ctr6.School = 6 creature_template_resistance ctr6 ON ct.entry = ctr6.CreatureID AND ctr6.School = 6
WHERE
ct.entry > ?d
{ {
AND ct.entry IN (?a) WHERE
ct.entry IN (?a)
} }
ORDER BY ORDER BY
ct.entry ASC ct.entry ASC
LIMIT LIMIT
?d'; ?d, ?d';
$dummyQuery = ' $dummyQuery = '
UPDATE UPDATE
@@ -157,14 +156,10 @@ SqlGen::register(new class extends SetupScript
c.iconString = cdi.iconString, c.iconString = cdi.iconString,
c.humanoid = IF(cdie.id IS NULL, 0, 1)'; c.humanoid = IF(cdie.id IS NULL, 0, 1)';
$lastMax = 0; $i = 0;
while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{ {
$newMax = max(array_column($npcs, 'entry')); CLI::write(' * batch #' . ++$i . ' (' . count($npcs) . ')');
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
$lastMax = $newMax;
foreach ($npcs as $npc) foreach ($npcs as $npc)
DB::Aowow()->query('REPLACE INTO ?_creature VALUES (?a)', array_values($npc)); DB::Aowow()->query('REPLACE INTO ?_creature VALUES (?a)', array_values($npc));

View File

@@ -131,24 +131,19 @@ SqlGen::register(new class extends SetupScript
spell_group sg ON sg.spell_id = it.spellid_1 AND it.class = 0 AND it.subclass = 2 AND sg.id IN (1, 2) spell_group sg ON sg.spell_id = it.spellid_1 AND it.class = 0 AND it.subclass = 2 AND sg.id IN (1, 2)
LEFT JOIN LEFT JOIN
game_event ge ON ge.holiday = it.HolidayId AND it.HolidayId > 0 game_event ge ON ge.holiday = it.HolidayId AND it.HolidayId > 0
WHERE
it.entry > ?d
{ {
AND it.entry IN (?a) WHERE
it.entry IN (?a)
} }
ORDER BY ORDER BY
it.entry ASC it.entry ASC
LIMIT LIMIT
?d'; ?d, ?d';
$lastMax = 0; $i = 0;
while ($items = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) while ($items = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{ {
$newMax = max(array_column($items, 'entry')); CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')');
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
$lastMax = $newMax;
foreach ($items as $item) foreach ($items as $item)
DB::Aowow()->query('REPLACE INTO ?_items VALUES (?a)', array_values($item)); DB::Aowow()->query('REPLACE INTO ?_items VALUES (?a)', array_values($item));

View File

@@ -76,17 +76,16 @@ SqlGen::register(new class extends SetupScript
gameobject_template_locale gtl8 ON go.entry = gtl8.entry AND gtl8.`locale` = "ruRU" gameobject_template_locale gtl8 ON go.entry = gtl8.entry AND gtl8.`locale` = "ruRU"
LEFT JOIN LEFT JOIN
gameobject_questitem gqi ON gqi.GameObjectEntry = go.entry gameobject_questitem gqi ON gqi.GameObjectEntry = go.entry
WHERE
go.entry > ?d
{ {
AND go.entry IN (?a) WHERE
go.entry IN (?a)
} }
GROUP BY GROUP BY
go.entry go.entry
ORDER BY ORDER BY
go.entry ASC go.entry ASC
LIMIT LIMIT
?d'; ?d, ?d';
$updateQuery = ' $updateQuery = '
UPDATE UPDATE
@@ -104,17 +103,13 @@ SqlGen::register(new class extends SetupScript
o.id IN (?a) o.id IN (?a)
}'; }';
$lastMax = 0; $i = 0;
while ($objects = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) while ($objects = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{ {
$newMax = max(array_column($objects, 'entry')); CLI::write(' * batch #' . ++$i . ' (' . count($objects) . ')');
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax); foreach ($objects as $object)
DB::Aowow()->query('REPLACE INTO ?_objects VALUES (?a)', array_values($object));
$lastMax = $newMax;
foreach ($objects as $o)
DB::Aowow()->query('REPLACE INTO ?_objects VALUES (?a)', array_values($o));
} }
// apply typeCat and reqSkill depending on locks // apply typeCat and reqSkill depending on locks

View File

@@ -129,15 +129,14 @@ SqlGen::register(new class extends SetupScript
game_event_seasonal_questrelation gesqr ON gesqr.questId = q.ID game_event_seasonal_questrelation gesqr ON gesqr.questId = q.ID
LEFT JOIN LEFT JOIN
disables d ON d.entry = q.ID AND d.sourceType = 1 disables d ON d.entry = q.ID AND d.sourceType = 1
WHERE
q.id > ?d
{ {
AND q.id IN (?a) WHERE
q.ID IN (?a)
} }
ORDER BY ORDER BY
q.ID ASC q.ID ASC
LIMIT LIMIT
?d'; ?d, ?d';
$xpQuery = ' $xpQuery = '
UPDATE UPDATE
@@ -171,17 +170,13 @@ SqlGen::register(new class extends SetupScript
}'; }';
$lastMax = 0; $i = 0;
while ($quests = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) while ($quests = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
{ {
$newMax = max(array_column($quests, 'ID')); CLI::write(' * batch #' . ++$i . ' (' . count($quests) . ')');
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax); foreach ($quests as $quest)
DB::Aowow()->query('REPLACE INTO ?_quests VALUES (?a)', array_values($quest));
$lastMax = $newMax;
foreach ($quests as $q)
DB::Aowow()->query('REPLACE INTO ?_quests VALUES (?a)', array_values($q));
} }
/* /*