Re: "Keyed" sequence?

From: Vik Fearing <vik(at)2ndquadrant(dot)fr>
To: Israel Brewster <israel(at)ravnalaska(dot)net>
Cc: "pgsql-general(at)postgresql(dot)org general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: "Keyed" sequence?
Date: 2016-04-28 19:01:01
Message-ID: 57225DED.5000007@2ndquadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/28/2016 08:48 PM, Israel Brewster wrote:
>>
>> On Apr 28, 2016, at 10:39 AM, Vik Fearing <vik(at)2ndquadrant(dot)fr> wrote:
>>
>> What would be the point of this? Why not just one sequence for all
>> departments?
>
> continuity and appearance, not to mention simple logical progression. In this case, the sequence is being used to generate a PO number. Company style indicates that a PO number is a department code followed by a unique number. With one sequence for all departments, you could (will) end up with discontinuous PO numbers in any given department. It would be nice if, after issuing PO number 15-1, the next PO in department 15 was 2, if for no other reason than the accounting department could easily see that they aren't missing any. With one sequence, there will quite likely not be a PO number 2 for any given department, so that department has no easy way to keep track of their PO's based on PO number.

You're not guaranteed that even with individual sequences.

What' you're looking for is a gapless sequence, which is best simulated
with a table. In your case, I'd just add a column to your existing
departments table holding the next number to use.

It'll kill your performance, but if aesthetics are that important to you...
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Joseph Krogh 2016-04-28 19:05:35 Re: "Keyed" sequence?
Previous Message John McKown 2016-04-28 18:59:57 Re: "Keyed" sequence?