Re: Using a postgres table to maintain unique id?

Поиск
Список
Период
Сортировка
От Michael Teter
Тема Re: Using a postgres table to maintain unique id?
Дата
Msg-id 20001114022241.6363.qmail@web10008.mail.yahoo.com
обсуждение исходный текст
Ответ на Using a postgres table to maintain unique id?  (Steve Wampler <swampler@noao.edu>)
Ответы Re: Using a postgres table to maintain unique id?  (Thomas Swan <tswan@olemiss.edu>)
Список pgsql-sql
> Can someone show me how to create (and use) an int8
> sequence?

From what I can tell (both from docs and doing a
describe on sequences in my database), a postgresql
sequence is an int4, not an int8, and thus you are
limited to a max of 2.1 billion values.

If you require an int8 sequence, you'll probably have
to manage your own and just use an int8 column.

> Fortunately, I don't want any number to ever get
> recycled - the id needs to
> be unique throughout the 25+ year lifetime of the
> project.  The table
> would have a single row with a single column. 
> Selecting that table cell
> would return the current value, but leave the value
> incremented in the
> table cell (it's ok if it increments the value
> before returning).

If 2.1 billion unique values is enough, then a
sequence will work fine.  Performance of sequence
should be ok.

An alternative you might consider is creating your own
"sequence server" external to the database.

Michael

__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Cristi Petrescu-Prahova"
Дата:
Сообщение: Re: how to continue a transaction after an error?
Следующее
От: Philip Warner
Дата:
Сообщение: Re: how to continue a transaction after an error?