Re: Increment a sequence by more than one

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Steve Midgley" <public(at)misuse(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Increment a sequence by more than one
Date: 2007-08-03 19:45:34
Message-ID: dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oh, another point. You should run the

alter sequence m increment 5000;
select nextval('m');
alter sequence m increment 1;

one right after the other to reduce the number of 5000 wide holes in
your sequence.

Or, given the size of bigint, you could just set the increment to 5000
and leave it there, and then any insert could grab nextval('m') and
insert up to 5000 more ids with monotonically increasing ids safely.

Note you wouldn't use defaults or nextvals for the rest, you'd have to
calculate them in your application.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Jones 2007-08-03 19:50:59 Re: Foreign Key inter databases
Previous Message Scott Marlowe 2007-08-03 19:42:59 Re: Increment a sequence by more than one