Skip site navigation (1) Skip section navigation (2)

Using a postgres table to maintain unique id?

From: Steve Wampler <swampler(at)noao(dot)edu>
To: postgres-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Using a postgres table to maintain unique id?
Date: 2000-11-13 17:13:06
Message-ID: 3A102122.33733FF1@noao.edu (view raw or flat)
Thread:
Lists: pgsql-sql
Hi,

I have a distributed application that needs unique 64-bit
"id" values.  The current implementation keeps the current
value for this id in a file on one system and uses
a process to provide access to this file via CORBA.

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

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?

Any tips on how to implement the trigger would be
appreciated.  (Is it possible to generate an int8 sequence
value?)

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

Responses

pgsql-sql by date

Next:From: Poet/Joshua DrakeDate: 2000-11-13 17:26:18
Subject: Re: Using a postgres table to maintain unique id?
Previous:From: Tom LaneDate: 2000-11-13 15:32:37
Subject: Re: shared memory problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group