Re: postgres metadata - Mailing list pgsql-general

From Tom Lane
Subject Re: postgres metadata
Date
Msg-id 19737.1069903905@sss.pgh.pa.us
Whole thread Raw
In response to Re: postgres metadata  (greg@turnstep.com)
List pgsql-general
greg@turnstep.com writes:
> The problem is that the oid column has no "unique" constraint ...

unless you add one, viz:

    create unique index mytable_oids on mytable (oid);

which is de rigueur for any table you intend to rely on OID as an
identifier for.  The index is needed not only to ensure uniqueness
but as a mechanism for fast access to a particular row by OID.

You should be aware though that once the OID counter wraps around (every
4 billion OIDs) there is a small chance that a newly-created OID will
duplicate a prior entry, resulting in a "duplicate key" failure in a
transaction that really didn't do anything wrong.  If you have a moral
aversion to writing retry loops in your client code then this will
disgust you.  My own take on it is that there are enough reasons why you
will need retry loops that one more shouldn't bug you.

These comments generally apply to SERIAL and the other alternatives
Greg mentioned, as well.  The only difference is how fast do the
identifiers get eaten and how far is it to the wraparound point ...

            regards, tom lane

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: disaster recovery
Next
From: Tom Lane
Date:
Subject: Re: disaster recovery