Re: Optimistic concurrency control

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Frank Millman <frank(at)chagford(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimistic concurrency control
Date: 2005-01-13 10:49:05
Message-ID: 20050113104905.GA7067@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 13, 2005 at 11:49:00AM +0200, Frank Millman wrote:
> I have been reading up on 'optimistic concurrency control'.
>
> The following quote is taken from the on-line help for MS SQL Server 2000 -

<snip>

> MS SQL Server uses a 'timestamp' column to check if a row has been
> altered since it was read. The equivalent in PostgreSQL seems to be
> the system column 'xmin'. However, the notes say 'You do not really
> need to be concerned about these columns, just know they exist.' Is
> it ok to use xmin for this purpose, or is there another way of
> achieving OCC?

PostgreSQL already has concurrency control, it's called MVCC, so within
a transaction you will only see a consistant version of the database
without taking any locks. If you want to emulate it on top of that
on over multiple transactions, remember xmin represents the transaction
that created it, not the timestamp it was changed. If you really want
timestamps you'll need to manage that yourself...

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2005-01-13 11:05:29 Re: Optimistic concurrency control
Previous Message Peter Childs 2005-01-13 10:29:42 Re: problems with 8.0 Rc4