Probably your instance restarts with a heap space error.
It is not possible, or at least it requires a lot of space to hold 800.000 entries in memory. So split this into batches.
BTW consider using OQL to compare data, because databases are built for that.
Hello,
This might lead into a huge problem and the runtime might be affected, try to retrieve using batches, and sort the retrieve based on a unique value and do a manual loop to complete it, it is recommended to retrieve 1000 object per retrieve as a max, do you know the how much core resources you’re using for your hosted application ?