Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 76ADE9FB3D2 for ; Fri, 3 Aug 2007 16:45:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 95865-04 for ; Fri, 3 Aug 2007 16:45:28 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.184]) by postgresql.org (Postfix) with ESMTP id 0494A9FA5FA for ; Fri, 3 Aug 2007 16:45:35 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id f1so629986rvb for ; Fri, 03 Aug 2007 12:45:34 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gV/hg9mCCY48Vjffb4Q1xHN43RRXdcbjg0bbeKhuHY0RjF6xyolrkEwzwrB9THNDTcPXkNGefBSNir4vqDWOXEWByabjjtFKO4TIxvriMwljje4yn99crXJ1911MtvWphBE6iA7uHYFG7tN5q3o375iOeraYRkV5rqBhqEyo7NA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HlfziVpyffIJTEchbVpFHhp7UjjaA0Nz2M+X10SiWm4OW8R2oi4AjB74Ra1PhrwbOu0h3CHfTUBKj//NKO6QlEm85B44IkxvEDxNZEaauXKq3ikLK+YprMZnpVwfx4zRJJokS8XvMOIJZAnKSWdr4bDKhRlaVXPMgJE6md2ps1w= Received: by 10.141.68.10 with SMTP id v10mr1175044rvk.1186170334822; Fri, 03 Aug 2007 12:45:34 -0700 (PDT) Received: by 10.141.162.12 with HTTP; Fri, 3 Aug 2007 12:45:34 -0700 (PDT) Message-ID: Date: Fri, 3 Aug 2007 14:45:34 -0500 From: "Scott Marlowe" To: "Steve Midgley" Subject: Re: Increment a sequence by more than one Cc: pgsql-sql@postgresql.org In-Reply-To: <46b381f2.0b86460a.3a8c.5460SMTPIN_ADDED@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070803165058.020509FBF2F@postgresql.org> <46b381f2.0b86460a.3a8c.5460SMTPIN_ADDED@mx.google.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/24 X-Sequence-Number: 28962 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.