Re: Understanding oid for a record

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brusser, Michael" <Michael(dot)Brusser(at)matrixone(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Understanding oid for a record
Date: 2006-12-18 18:04:40
Message-ID: 20841.1166465080@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Brusser, Michael" <Michael(dot)Brusser(at)matrixone(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2006-12-18 18:04:45 Re: pg_restore fails with a custom backup file
Previous Message Richard Huxton 2006-12-18 18:00:32 Re: Understanding oid for a record