Re: [GENERAL] Get block of N numbers from sequence

2009-05-20 Thread Merlin Moncure
On Wed, May 20, 2009 at 3:00 AM, Thomas Guettler wrote: > Thomas Guettler schrieb: >> Hi, > >> how can you get N numbers (without holes) from a sequence? >> > > If sequences could be locked like tables, it would be easy. advisory locks are superior for locking sequences in almost every way m

Re: [GENERAL] Get block of N numbers from sequence

2009-05-20 Thread Thomas Guettler
Thomas Guettler schrieb: > Hi, > > how can you get N numbers (without holes) from a sequence? > If sequences could be locked like tables, it would be easy. In old versions of postgres it worked: http://archives.postgresql.org//pgsql-hackers/2001-10/msg00930.php Thomas -- Thomas Guettler

Re: [GENERAL] Get block of N numbers from sequence

2009-05-20 Thread Thomas Guettler
Boszormenyi Zoltan schrieb: > Thomas Guettler írta: >> Hi, >> >> how can you get N numbers (without holes) from a sequence? > # create sequence tmp_seq cache 1000; Hi, "alter SEQUENCE ... cache 100" survives a rollback. That's something I like to avoid: foo_esg_modw=# select * from foo_isu_is

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread Craig Ringer
Merlin Moncure wrote: > On Tue, May 19, 2009 at 9:32 AM, Thomas Guettler wrote: >> >> hubert depesz lubaczewski schrieb: >>> On Tue, May 19, 2009 at 01:45:17PM +0200, Thomas Guettler wrote: how can you get N numbers (without holes) from a sequence? >>> alter sequence XXX increment by 1000; >>

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread Merlin Moncure
On Tue, May 19, 2009 at 9:32 AM, Thomas Guettler wrote: > > > hubert depesz lubaczewski schrieb: >> On Tue, May 19, 2009 at 01:45:17PM +0200, Thomas Guettler wrote: >>> how can you get N numbers (without holes) from a sequence? >> >> alter sequence XXX increment by 1000; >> select nextval('XXX');

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread Boszormenyi Zoltan
Thomas Guettler írta: > Hi, > > how can you get N numbers (without holes) from a sequence? > > Thomas > > # create sequence tmp_seq cache 1000; CREATE SEQUENCE >From the same client: # select nextval('tmp_seq'); nextval - 1 (1 sor) # select nextval('tmp_seq'); nextval --

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread hubert depesz lubaczewski
On Tue, May 19, 2009 at 03:32:16PM +0200, Thomas Guettler wrote: > If other processes run nextval() between "increment by 1000" and "increment > by 1", > they leave big holes in the sequence. yes. I know. there is no other way. if you want 1000 ids, but they don't have to be consequtive, you can

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread hubert depesz lubaczewski
On Tue, May 19, 2009 at 01:45:17PM +0200, Thomas Guettler wrote: > how can you get N numbers (without holes) from a sequence? alter sequence XXX increment by 1000; select nextval('XXX'); alter sequence XXX increment by 1; Best regards, depesz -- Linkedin: http://www.linkedin.com/in/depesz /

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread Thomas Guettler
hubert depesz lubaczewski schrieb: > On Tue, May 19, 2009 at 01:45:17PM +0200, Thomas Guettler wrote: >> how can you get N numbers (without holes) from a sequence? > > alter sequence XXX increment by 1000; > select nextval('XXX'); > alter sequence XXX increment by 1; If other processes run next

Re: [GENERAL] Get block of N numbers from sequence

2009-05-19 Thread Grzegorz Jaśkiewicz
On Tue, May 19, 2009 at 12:45 PM, Thomas Guettler wrote: > Hi, > > how can you get N numbers (without holes) from a sequence? generate_series(), or make sure there's only one connection, no transactions rollback. -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To

[GENERAL] Get block of N numbers from sequence

2009-05-19 Thread Thomas Guettler
Hi, how can you get N numbers (without holes) from a sequence? Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.