Function list_staying() used in backout and undo processes have complexity O(N^2), where N is the number of back versions.
There is a way to reduce complexity down to O(N) in most cases. Specifically - when current transaction (which does backout
or undo) already own the record (i.e. primary record version is marked by current transaction) there is guarantee that no other
transaction will try to backout\undo the record.
Another improvement is to cut and cleanup tail of the back-versions chain at point where it is legal