Re: Postgres 8.3 HOT and non-persistent xids - Mailing list pgsql-general

From Tom Lane
Subject Re: Postgres 8.3 HOT and non-persistent xids
Date
Msg-id 4486.1198130102@sss.pgh.pa.us
Whole thread Raw
In response to Postgres 8.3 HOT and non-persistent xids  ("Mike C" <smith.not.western@gmail.com>)
Responses Re: Postgres 8.3 HOT and non-persistent xids
Re: Postgres 8.3 HOT and non-persistent xids
List pgsql-general
[ Pavan already answered most of this, but ... ]

"Mike C" <smith.not.western@gmail.com> writes:
> And for non-persistent transaction ids, the documentation says that
> this is for read-only transactions. What defines a read-only
> transaction for this purpose?

A transaction that has not done anything that requires it to sign an
update with its transaction ID.

> Does postgres check to see if a SELECT
> includes e.g. a sequence change via nextval?

IIRC, nextval() doesn't involve marking anything with one's XID,
because it is not a rollback-able operation.  But you are thinking
at quite the wrong level if you suppose that this behavior has anything
to do with "checking a SELECT for a writing operation".  The way it
really works is that a backend generates a persistent XID for its
current transaction at the instant that some bit of code first demands
the transaction's XID.  Typically this happens because you insert,
update, or delete some tuple, and the XID is needed to set xmin or xmax
of the tuple.  There are some other cases, but they are covered by
definition, because there is no way to get the current XID except to ask
that code for it.

> If I mark the transaction
> as readonly using the PG JDBC driver, will that be sufficient?

If this means what I think it means, it's irrelevant.  Materializing a
persistent XID is driven off what the transaction *actually* does,
not off whether it's declared to be read-only or not.

            regards, tom lane

pgsql-general by date:

Previous
From: "Pavan Deolasee"
Date:
Subject: Re: Postgres 8.3 HOT and non-persistent xids
Next
From: Andrew Nesheret
Date:
Subject: Re: foreign key constraint, planner ignore index.