Thread: What is xmin ?

What is xmin ?

From
Antony Paul
Date:
Hi,
    I read about xmin in a thread on optimistic concurrency control.
Can you guys tell me how to interpret this value. I want to convert
this to date format. Is it possible ?

rgds
Antony Paul

Re: What is xmin ?

From
Karsten Hilbert
Date:
> Can you guys tell me how to interpret this value. I want to convert
> this to date format. Is it possible ?
No.

XMIN holds the id of the transaction which did the most recent
change to a row as is visible from within the current
transaction. Unless it wraps around (is that possible ?) older
transactions should have XMIN values lower than younger
transactions.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

Re: What is xmin ?

From
Alvaro Herrera
Date:
On Tue, Jan 18, 2005 at 02:43:09PM +0100, Karsten Hilbert wrote:

> XMIN holds the id of the transaction which did the most recent
> change to a row as is visible from within the current
> transaction. Unless it wraps around (is that possible ?) older
> transactions should have XMIN values lower than younger
> transactions.

Yes, it wraps around, that's why modulo arithmetic is used internally to
handle it.  Beyond that, it skips a few (3 or 4) special values just
above zero.

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"There was no reply" (Kernel Traffic)

Re: What is xmin ?

From
Martijn van Oosterhout
Date:
On Tue, Jan 18, 2005 at 02:43:09PM +0100, Karsten Hilbert wrote:
> > Can you guys tell me how to interpret this value. I want to convert
> > this to date format. Is it possible ?
> No.
>
> XMIN holds the id of the transaction which did the most recent
> change to a row as is visible from within the current
> transaction. Unless it wraps around (is that possible ?) older
> transactions should have XMIN values lower than younger
> transactions.

Correct. XMIN is a transaction ID and it can wraparound. To counter
this there is a special XMIN value which means "older than any
transaction". Which the reason you must run VACUUM at least once every
billion transactions or so. Hardly a difficult request :)

There is no way to convert it to a date, since it doesn't represent a
date or even a point in time. It represents a transaction and how it
relates to other transactions.

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

Re: What is xmin ?

From
Christopher Browne
Date:
In an attempt to throw the authorities off his trail, antonypaul24@gmail.com (Antony Paul) transmitted:
>     I read about xmin in a thread on optimistic concurrency control.
> Can you guys tell me how to interpret this value. I want to convert
> this to date format. Is it possible ?

xmin is a transaction ID number.  There is no such conversion
possible.

http://www.faqs.org/docs/ppbook/x4636.htm

It would be kind of neat if there were some table into which
transactions were logged; in that case, there would presumably be a
couple of timestamps, namely the time at which the transaction began
and the time at which the transaction ended.  There is no such table
by default.
--
wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org').
http://www.ntlug.org/~cbbrowne/languages.html
We are in fact well and truly doomed.
-- Jamie Zawinski http://www.jwz.org/gruntle/nscpdorm.html

Re: What is xmin ?

From
Alvaro Herrera
Date:
On Tue, Jan 18, 2005 at 01:16:55PM -0500, Christopher Browne wrote:

> It would be kind of neat if there were some table into which
> transactions were logged; in that case, there would presumably be a
> couple of timestamps, namely the time at which the transaction began
> and the time at which the transaction ended.  There is no such table
> by default.

It would be useful in a savepoints' world only if accompanied by the
time a subtransaction began and ended, and the information about
parent/child relationship.

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"Tiene valor aquel que admite que es un cobarde" (Fernandel)