You'd expect faster results with an index on snapshot_id or object_id (preferably whichever of those has fewer duplicates). One could imagine the current plan is roughly - Look at every record until you find snapshot_id==3 -- Look at every record until you find matching object_id and snapshot_id==5. Update dst if/when you find the match. That outer loop executes 24k times, and the inner loop might execute 24k times for each call of the outer loop, for a total of 24k*24k = half a billion times. If there are very few duplicate object_id's, an index on object_id substantially reduces the work for the inner loop. If there are very few duplicate snapshot_id, an index there substantially reduces the work for both loops.