Hi there @TotalDataLoss,
have read both of your topics, investigated a bit and gave it a thought. So in theory Window Loop should be used in this case. However problem with duplication you are seeing is known and there is ticket in system to handle it (internal reference: AP-11610). Considering that and amount of data you have (which causes slowness and memory issues) I suggest different approach (without a loop). Will add my suggestion into new topic - once I polish it successfully
Br,
Ivan