The function I mentioned crashes our upgrades to BC19 on a regular basis. - It lets the SQL Server run out of Memory (16GB) after about 12 Hours. on a single company with just 22k Items. The code in this upgrade codeunit doesn't look too bad, but is very inefficient as it loops every Items and reads the groups whenever an item has a Prod Group set instead of doing it the other way around
so my suggestion is to replace your current function with this:
procedure UpgradeItemPostingGroups()
var
Item: Record "Item";
GenProdPostingGroup: Record "Gen. Product Posting Group";
InventoryPostingGroup: Record "Inventory Posting Group";
UpgradeTagDefinitions: Codeunit "Upgrade Tag Definitions";
UpgradeTag: Codeunit "Upgrade Tag";
begin
if UpgradeTag.HasUpgradeTag(UpgradeTagDefinitions.GetItemPostingGroupsUpgradeTag()) then
exit;
GenProdPostingGroup.SetLoadFields(Code);
if GenProdPostingGroup.FindSet() then
repeat
item.SetRange("Gen. Prod. Posting Group", GenProdPostingGroup.Code);
Item.ModifyAll("Gen. Prod. Posting Group Id", GenProdPostingGroup.SystemId);
until GenProdPostingGroup.Next() = 0;
InventoryPostingGroup.SetLoadFields(Code);
if InventoryPostingGroup.FindSet() then
repeat
item.SetRange("Inventory Posting Group", InventoryPostingGroup.Code);
Item.ModifyAll("Inventory Posting Group Id", InventoryPostingGroup.SystemId);
until InventoryPostingGroup.Next() = 0;
UpgradeTag.SetUpgradeTag(UpgradeTagDefinitions.GetItemPostingGroupsUpgradeTag());
end;
p.s. the file you need to edit is found in \Upgrade\UpgradeBaseApp.Codeunit.al

Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team