diff --git a/common/database.cpp b/common/database.cpp index 63982568b..28d7eafce 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -2299,11 +2299,26 @@ void Database::ConvertInventoryToNewUniqueId() } TransactionBegin(); + uint32 index = 0; + uint32 batch_size = 1000; + std::vector queue{}; + queue.reserve(batch_size); + for (auto &r: results) { r.item_unique_id = EQ::UniqueHashGenerator::generate(); + queue.push_back(r); + index++; + if (index >= batch_size) { + InventoryRepository::ReplaceMany(*this, queue); + index = 0; + queue.clear(); + } + } + + if (!queue.empty()) { + InventoryRepository::ReplaceMany(*this, queue); } - InventoryRepository::ReplaceMany(*this, results); TransactionCommit(); LogInfo("Converted {} records", results.size()); } \ No newline at end of file