Re: mvcc & DML on the same row

From: Robert Haas <robertmhaas(at)gmail(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-15 21:35:34
Message-ID: AANLkTi=xSUjKWHnpEo6pkiKkEw0Bv4eAv5R3SgzvPtDj@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 15, 2010 at 2:50 PM, matteo durighetto
<desmodemone(at)gmail(dot)com> wrote:
> Hi,
>    I have an idea about mvcc and different DML of the same row in the
> same transaction.
> Normally when a backend do an unpdate on a row ( call it X ) , we done
> an insert and logical delete on this row  (0,1,2..N are the "version
> of the row) :
>
>   X0  (delete "old" row)
>   X1  (insert  "new" row)
>
> 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  )
>
>
> But why we need all these versions of the same row on table, if for
> rollback we need only the original row X (X0) ?

The fact that we can't get rid of X1 until after the transaction
commits is an implementation limitation. But you obviously need both
X0 and X2, because the transaction might either commit or abort.

> So I think we need it in memory, not on physical space of table (ok
> there is the cache, but ..) or something similar, or this method is
> for transaction with isolation level at "read uncommited"?

I can't figure out exactly what this part is talking about. It's
completely impractical to add rows to a table without writing them
into shared buffers, which means they will eventually get flushed to
disk if not vacuumed, dropped, etc. first. We don't support read
uncommitted anyway (well, we do, but it's really still snapshot
isolation).

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nicolas Barbier 2010-12-15 21:35:57 Re: mvcc & DML on the same row
Previous Message Tom Lane 2010-12-15 21:26:26 Re: Complier warnings on mingw gcc 4.5.0