Re: creating "a perfect sequence" column

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: zidibik(at)yahoo(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: creating "a perfect sequence" column
Date: 2008-07-07 01:02:30
Message-ID: dcc563d10807061802h1c255b10md5bff07a99662275@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jul 6, 2008 at 6:15 PM, Jack Brown <zidibik(at)yahoo(dot)com> wrote:
> Dear list,
>
> I need some tips and/or pointers to relevant documentation implementing (what I chose to call) "a perfect sequence" i.e. a sequence that has no missing numbers in the sequence. I'd like it to auto increment on insert, and auto decrement everything bigger than its value on delete. There are many mechanisms (rules, triggers, sequences, locks etc.) but I'm not sure which combination would result in the most elegant implementation.

This would actually be a perfectly awful sequence. :) Seriously,
it's costly to lock the whole table, set the sequence to the last
available value and lock it in terms of concurrency.

>
> Oh, and if you know the right term for what I just described, I'd be more than pleased to hear it! :-)

I believe it's called a "How to destroy concurrency" or something like that.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Berend Tober 2008-07-07 01:33:40 Re: creating "a perfect sequence" column
Previous Message Jack Brown 2008-07-07 00:15:27 creating "a perfect sequence" column