Mulit-Vesions and Vacuum

From: Anthony Berglas <anthony(dot)berglas(at)lucida(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Mulit-Vesions and Vacuum
Date: 2002-07-19 01:43:03
Message-ID: E6062644D006474BAEB2A3933C1C459C22FE45@lucidamail.lucidainc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello All,

Does anyone really know how this multi version concurrency really works?

The basic idea is simple, never update anything so that you can always get
read-consistent queries by reading behind the updates. But the details are
missing in the docs. In particular:-

1. How long do previous version hang arround? As long as the oldest
transaction, or until a Vacuum?

2. How expensive are they? Do the multi-version copies clutter the main
database blocks, or are they stored elsewhere? And if I update one field of
a row, is the entire row copied or just the field?

3. What does Vacuum really do? Will it interfere with open transactions, or
will it know to leave multi version copies for existing transactions?

PS. I have done a few experiements on how the locking really works, see
http://www.SimpleORM.org/DBNotes.html. Note the difference with Oracle,
which I think is better and easy to implement given the basic MV approach.

PPS. Design issues:-

1. Why not just use the transaction log to implement MV? Each record only
needs to store a pointer into the logs to the previous update. And the logs
would log that pointer, forming a backward pointing linked list. Most of
the time this will not be needed, or will refer to a very recently written
tail of the log which will already be cached in memory. This approach
would put an end to Oracle's issus with running out of "Rollback Segments".
It would also put an end to Postgres performance problems on inserts and
updates -- why be slower than MySQL? You need a transaction log anyway, so
no extra overhead should be added for MV unless a query actually needs to
read behind updated data.

2. If you are going to go to the trouble of keeping multi versions for
locking, why not make them available for the application as well? One of
the painful features to implement is audit trails of how records get to be
the way they are. The database could do that automatically.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-07-19 02:28:55 Re: Mulit-Vesions and Vacuum
Previous Message Martijn van Oosterhout 2002-07-19 00:52:02 Re: 7.3 support for IN