mlw <markw@mohawksoft.com> writes:
> I guess I don't understand. Why does it have to visit all of them?
Because it doesn't have any way to know in advance which one(s) are
visible to it.
> If ordering
> them from newest tom oldest, and then take the first transaction ID that it
> smaller then current transaction id, doesn't that work?
No. For starters, we couldn't guarantee that insertion order is the
same as transaction commit order. Even if we did, your assumption
that commit order is the same as visibility is too simplistic. And
none of this works if the index isn't unique.
regards, tom lane