Re: Using a postgres table to maintain unique id?

From: Steve Wampler <swampler(at)noao(dot)edu>
To: Poet/Joshua Drake <poet(at)linuxports(dot)com>
Cc: postgres-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Using a postgres table to maintain unique id?
Date: 2000-11-13 17:44:21
Message-ID: 3A102875.C545E345@noao.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Poet/Joshua Drake wrote:
>
> >However, I also use Postgres (7.0.2) throughout this
> >application and it seems cleaner to me to keep the current
> >id value in a table and just use postgres to provide access
> >(with a trigger function to increment the id on access).
>
> Why not a sequence?

Can someone show me how to create (and use) an int8 sequence?

> >Is this reasonable? Is it fast? (I need 10 or more IDs
> >generated each second.) Can I avoid having the table
> >gradually fill with "old" rows for this entry, and this
> >avoid the need to run VACUUM ANALYZE periodically?
>
> The only problem I have had with this type of thing is when a number gets
> deleted, it does not get recycled.

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).

--
Steve Wampler- SOLIS Project, National Solar Observatory
swampler(at)noao(dot)edu

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Forest Wilkinson 2000-11-13 18:53:58 Re: Using a postgres table to maintain unique id?
Previous Message Poet/Joshua Drake 2000-11-13 17:26:18 Re: Using a postgres table to maintain unique id?