Is there some reason for using a slightly different "skipping" algorithm in the indexed case vs. the seqscan case -- one based on tuple equality, the other based on value equality for exactly one arbitrarily chosen tuple. The possibility of breaking out of the loop early on the second existingValue match -- regardless of whether either match was in fact on the oldTuple suggests that the skippedOne algorithm may be preferable.