pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <scott.marlowe@gmail.com>
To: Steve Midgley <public@misuse.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Increment a sequence by more than one
Date: Fri, 3 Aug 2007 14:45:34 -0500
Message-ID: <dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com> (raw)
In-Reply-To: <46b381f2.0b86460a.3a8c.5460SMTPIN_ADDED@mx.google.com>
References: <20070803165058.020509FBF2F@postgresql.org>
	<dcc563d10708031201r1e741c13od9abd2eadb0e95cf@mail.gmail.com>
	<46b381f2.0b86460a.3a8c.5460SMTPIN_ADDED@mx.google.com>

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.



view thread (11+ messages)  latest in thread

Message-ID: <dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com>
Permalink:  ../dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com/
Also on:    postgresql.org/message-id/dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: scott.marlowe@gmail.com, public@misuse.org
  Subject: Re: Increment a sequence by more than one
  In-Reply-To: <dcc563d10708031245j6698a5a2rda51a21e666f14b@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox