Re: Optimistic concurrency control - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Optimistic concurrency control
Date
Msg-id 20050113104905.GA7067@svana.org
Whole thread Raw
In response to Optimistic concurrency control  ("Frank Millman" <frank@chagford.com>)
List 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@svana.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.

Attachment

pgsql-general by date:

Previous
From: Peter Childs
Date:
Subject: Re: problems with 8.0 Rc4
Next
From: Peter Eisentraut
Date:
Subject: Re: Optimistic concurrency control