OIDs - can they be used for accessing records ?

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

OIDs - can they be used for accessing records ?

От:
Derek Clarkson <dhc@bigpond.net.au>
Дата:
Hello everyone.
	I am currently designing a DB and was wondering whether the OIDs assigned to 
each record could also be used as foreign keys links ? is this a good idea 
instead of using sequences ? Pros ? Cons ? 


-- 
Derek Clarkson
Web: http://users/bigpond/net/au/drekka

Re: OIDs - can they be used for accessing records ?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Derek Clarkson  writes:
> 	I am currently designing a DB and was wondering whether the OIDs assigned to 
> each record could also be used as foreign keys links ? is this a good idea 
> instead of using sequences ? Pros ? Cons ? 

It's usually considered a bad idea, mainly because there's no good way
to dump and reload the data (well, you can use pg_dump's -o switch,
but that's a kluge).  Also you have little or no control over the
possibility of OID wraparound leading to key conflicts.  Sequences are
a much cleaner solution.

Be careful to keep track of whether you're using int4 or int8 sequence
values, and declare the foreign key referencing columns to match.  You
will take a nasty performance hit if they don't match.

			regards, tom lane
FAQ