Thread: sequences w/o holes

sequences w/o holes

From
"Marian Naghen"
Date:
Can anyones suggest some readings about implementing
sequences w/o holes ?
 
 
thanx in advance.

Re: sequences w/o holes

From
Tino Wildenhain
Date:
Marian Naghen schrieb:
> Can anyones suggest some readings about implementing
> sequences w/o holes ?

not w/o a busload of race conditions and/or heavy locking.
Usually you want to avoid this.
So are you really sure you dont just want if for cosmetics?

Re: sequences w/o holes

From
Michael Glaesemann
Date:
On Dec 19, 2005, at 20:14 , Marian Naghen wrote:

> Can anyones suggest some readings about implementing
> sequences w/o holes ?

Check the mailing list archives. In short, if you want to guarantee
no holes, you don't use sequences. IIRC, the process is:
1. Set up another table (foo) that holds the current value.
2. To grab a new value,  increment the current value in foo and use
the current value in your insert within a transaction.

If you delete rows from your table, you'll need to do some updating
if you want to maintain having no holes.

Michael Glaesemann
grzm myrealbox com


Re: sequences w/o holes

From
Guido Neitzer
Date:
On 19.12.2005, at 12:14 Uhr, Marian Naghen wrote:

> Can anyones suggest some readings about implementing
> sequences w/o holes ?

Question: why?

I doubt that this is possible without heavy locking, which kills your
performance.

cug


--
PharmaLine Essen, GERMANY and
Big Nerd Ranch Europe - PostgreSQL Training, Feb. 2006, Rome, Italy
http://www.bignerdranch.com/classes/postgresql.shtml



Attachment