I have a completely blank custom table (DatabaseLogFixLog) with only one field/column called “refRecId”. I am joining it to SysDatabaseLog (log). The plan is to update SysDatabaseLog in batches, and as I update the SysDatabaseLog, I’ll insert the recId of the row I updated. My SysDatabaseLog has 3.7 million records in it. I have tried both notexists join and outer join seen below. What’s wrong with my code? Both just completely lock up my system, and the debugger will not get inside the loops.
Outer join:
updateCounter = 10;
while select forupdate log
order by CreatedDateTime, RecId
outer join databaseLogFixLog
where databaseLogFixLog.RefRecId != log.RecId
{
counter++;
if (counter > updateCount)
break;
info(strfmt("%1", counter));
}
info(strfmt("Done updating %1", counter));
Notexists join:
updateCounter = 10;
while select forupdate log
order by CreatedDateTime, RecId
notexists join databaseLogFixLog
where databaseLogFixLog.RefRecId == log.RecId
{
counter++;
if (counter > updateCount)
break;
info(strfmt("%1", counter));
}
info(strfmt("Done updating %1", counter));
Your two joins are not equivalent, your outer join is just plain wrong.
You exists join will work, but it will have to sort your log records (3.7 million), witch will take some time. Also it have to check for the whether you
logFixLogrecord exist (for each of the 3.7 million), you will need an index on theRefRecIdfield to speed things up.If you want speed then remove the
order byclause.You could also try the adding the
firstfastkeyword, it will sometimes giver faster initial results (but rarely if combined withorder by).Finally, select the fields you want to update, especially avoid the container field as this field is not stored with the other fields.