Re: "Keyed" sequence?

From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: "Keyed" sequence?
Date: 2016-04-28 19:05:35
Message-ID: VisenaEmail.42.5c22ae10fd0c1bae.1545e41c099@tc7-visena
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

På torsdag 28. april 2016 kl. 20:30:20, skrev Israel Brewster <
israel(at)ravnalaska(dot)net <mailto:israel(at)ravnalaska(dot)net>>:
This is probably crazy talk, but in Postgresql is there any way to have a
"keyed" sequence? That is, I have a table with a list of departments. While
*relatively* static, technically speaking this is a dynamic list - someone
certainly could decide to add a department, or combine two departments into one
new one, whatever. In any case, I would ideally like to have a sequence per
department, but since the list is dynamic it's not as simple as creating 33
independent sequences and then having a lookup table somewhere, although I
guess I could implement something of the sort with triggers. 
Is there any elegant way of accomplishing this? Something like SELECT
nextval('department_seq['ops'])?
 
Maybe this will help you:
http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram
 
Then you can do:
"id" bigint NOT NULL DEFAULT insta5.next_id(),
 
-- Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas(at)visena(dot)com <mailto:andreas(at)visena(dot)com>
www.visena.com <https://www.visena.com>
<https://www.visena.com>

 

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Israel Brewster 2016-04-28 19:09:14 Re: "Keyed" sequence?
Previous Message Vik Fearing 2016-04-28 19:01:01 Re: "Keyed" sequence?