Обсуждение: Can you run out of oids?

Поиск
Список
Период
Сортировка

Can you run out of oids?

От
"Chris Hoover"
Дата:
Somewhat silly question, but is it possible to run out of OID's?

Since we upgraded to 8.1.3, I noticed that I can create tables without an oid column.  I am wondering if I should consider trying to rebuild the existing tables to be built without OID. 

If it is possible to run out of OID's, how can you tell how close you are to the edge.

Thanks,

Chris

RH4.0
PG8.1.3

Re: Can you run out of oids?

От
Martijn van Oosterhout
Дата:
On Tue, Aug 01, 2006 at 02:02:18PM -0400, Chris Hoover wrote:
> Somewhat silly question, but is it possible to run out of OID's?

Nope. When you reach 4 billion, they just start again at zero.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

Re: Can you run out of oids?

От
Michael Fuhr
Дата:
On Tue, Aug 01, 2006 at 02:02:18PM -0400, Chris Hoover wrote:
> Somewhat silly question, but is it possible to run out of OID's?

It depends on what you mean by "run out."  As the FAQ and documentation
mention, OIDs wrap around and aren't guaranteed to be unique.

http://www.postgresql.org/docs/faqs.FAQ.html#item4.12
http://www.postgresql.org/docs/8.1/interactive/datatype-oid.html
http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html

> Since we upgraded to 8.1.3, I noticed that I can create tables without an
> oid column.  I am wondering if I should consider trying to rebuild the
> existing tables to be built without OID.

Avoid using OIDs; if you need a unique identifier use a serial or
bigserial column.

--
Michael Fuhr

Re: Can you run out of oids?

От
"Joshua D. Drake"
Дата:
Martijn van Oosterhout wrote:
> On Tue, Aug 01, 2006 at 02:02:18PM -0400, Chris Hoover wrote:
>> Somewhat silly question, but is it possible to run out of OID's?
>
> Nope. When you reach 4 billion, they just start again at zero.

O.k. but there is a catch.. if you are using them, they can and will
wrap. So don't use OIDs.

Joshua D. Drake


>
> Have a nice day,



    === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
    Providing the most comprehensive  PostgreSQL solutions since 1997
              http://www.commandprompt.com/



Re: Can you run out of oids?

От
Tom Lane
Дата:
"Chris Hoover" <revoohc@gmail.com> writes:
> Since we upgraded to 8.1.3, I noticed that I can create tables without an
> oid column.  I am wondering if I should consider trying to rebuild the
> existing tables to be built without OID.

As things are currently set up, a table that's uselessly using OIDs
isn't going to have any serious impact on any other table.  It might be
worth doing ALTER .... SET WITHOUT OIDS just to save the microseconds
required to generate an OID for each insert --- but I don't see another
reason.

            regards, tom lane