Unix Technical Forum

oids as primary keys?

This is a discussion on oids as primary keys? within the pgsql Novice forums, part of the PostgreSQL category; --> hi , someone has drawn my attention to the fact that oids may not be such a good idea ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 08:42 PM
Cima
 
Posts: n/a
Default oids as primary keys?

hi ,

someone has drawn my attention to the fact that oids may not be such a good
idea to set as a primary key in a table. i have designed a relativley large
database and defined oids as primary keys. i would like your opinions or
recomendations on this.


thanx.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:43 PM
Olivier Thauvin
 
Posts: n/a
Default Re: oids as primary keys?

Le Saturday 16 April 2005 00:42, Cima a écrit :
> hi ,
>
> someone has drawn my attention to the fact that oids may not be such a good
> idea to set as a primary key in a table. i have designed a relativley large
> database and defined oids as primary keys. i would like your opinions or
> recomendations on this.


It's surelly me, I reply to you directly instead to the list

About this I find where I read the warning:
http://www.postgresql.org/docs/8.0/i...atype-oid.html

where you can read:

"The oid type is currently implemented as an unsigned four-byte integer.
Therefore, it is not large enough to provide database-wide uniqueness in
large databases, or even in large individual tables. So, using a user-created
table's OID column as a primary key is discouraged. OIDs are best used only
for references to system tables."

Notice it is maybe not a problem for you currently.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQBCX+TSk29cDOWzfVARAkt+AKC/NwRFRH0VBnWrJC4pupE1dtzSkwCglnu3
H2Ri60tDpL61EJS0HfWLkHY=
=dEbs
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 08:43 PM
Frank Bax
 
Posts: n/a
Default Re: oids as primary keys?

At 06:42 PM 4/15/05, Cima wrote:
>someone has drawn my attention to the fact that oids may not be such a good
>idea to set as a primary key in a table. i have designed a relativley large
>database and defined oids as primary keys. i would like your opinions or
>recomendations on this.


http://www.postgresql.org/docs/faqs.FAQ.html#4.12


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 08:43 PM
Michael Fuhr
 
Posts: n/a
Default Re: oids as primary keys?

On Fri, Apr 15, 2005 at 03:42:40PM -0700, Cima wrote:
>
> someone has drawn my attention to the fact that oids may not be such a good
> idea to set as a primary key in a table. i have designed a relativley large
> database and defined oids as primary keys. i would like your opinions or
> recomendations on this.


See "Object Identifier Types" in the "Data Types" chapter of the
documentation:

http://www.postgresql.org/docs/8.0/i...atype-oid.html

"The oid type is currently implemented as an unsigned four-byte
integer. Therefore, it is not large enough to provide database-wide
uniqueness in large databases, or even in large individual tables.
So, using a user-created table's OID column as a primary key is
discouraged. OIDs are best used only for references to system
tables."

See also "What is an OID? What is a TID?" in the FAQ:

http://www.postgresql.org/docs/faqs.FAQ.html#4.12

"OIDs are autotomatically assigned unique 4-byte integers that are
unique across the entire installation. However, they overflow at
4 billion, and then the OIDs start being duplicated."

"To uniquely number columns in user tables, it is best to use SERIAL
rather than OIDs because SERIAL sequences are unique only within a
single table and are therefore less likely to overflow. SERIAL8
is available for storing eight-byte sequence values."

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com