Re: Understanding oid for a record - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Understanding oid for a record
Date
Msg-id 20841.1166465080@sss.pgh.pa.us
Whole thread Raw
In response to Understanding oid for a record  ("Brusser, Michael" <Michael.Brusser@matrixone.com>)
List pgsql-hackers
"Brusser, Michael" <Michael.Brusser@matrixone.com> writes:
> Can I assume that oid for any new record will be larger than oid on any
> other existing rows?

No; that will fail once the installation has consumed 4G OIDs.  The
counter just wraps around.

However, if you pay attention to the OID value returned in the INSERT
command result, you could fetch that and not have to assume anything
about max().

You will want to create a unique index on OID if you are using it this
way, first for efficiency of the fetch and second to prevent the
creation of duplicate entries after wraparound.

If you expect more than perhaps 100M rows in the table, you probably
need to think of another way, because of the likelihood of OID collisions.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Understanding oid for a record
Next
From: Magnus Hagander
Date:
Subject: Re: pg_restore fails with a custom backup file