Re: mvcc & DML on the same row

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: matteo durighetto <desmodemone(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: mvcc & DML on the same row
Date: 2010-12-16 14:11:01
Message-ID: 1292508661.1193.3161.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2010-12-15 at 20:50 +0100, matteo durighetto wrote:
> if we continue the transaction and we do for example another update
> on this row (X) , we again redo the same operation:
>
> X0 (deleted "old" row)
> X1 (row inserted, NOW deleted) => not needed for rollback
> X2 (insert "new" row )

This situation has a simple user-space solution: only make one update to
a row, rather than two.

> But why we need all these versions of the same row on table, if for
> rollback we need only the original row X (X0) ?

X1 cannot be removed because X0 points to it, via its t_ctid field.

In order to remove X1 we would need to change X0 to point to X2, which
we don't do because we're not allowed to update in place. Even if we
could, I'm not sure this case is frequent enough to be worth the effort.

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nicolas Barbier 2010-12-16 14:11:51 Re: Extensions, patch v18 (merge against master, bitrot-only-fixes)
Previous Message Robert Haas 2010-12-16 14:09:55 Re: SQL/MED - file_fdw