Re: Increment a sequence by more than one - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: Increment a sequence by more than one
Date
Msg-id dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com
Whole thread Raw
In response to Increment a sequence by more than one  (Steve Midgley <public@misuse.org>)
List 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.


pgsql-sql by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Increment a sequence by more than one
Next
From: Erik Jones
Date:
Subject: Re: Foreign Key inter databases