X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C0E35D7C3B for ; Mon, 7 Nov 2005 20:01:05 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29933-02 for ; Tue, 8 Nov 2005 00:01:02 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id E124AD7C12 for ; Mon, 7 Nov 2005 20:01:03 -0400 (AST) Received: (qmail 8738 invoked from network); 8 Nov 2005 00:01:05 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 8 Nov 2005 00:01:05 -0000 In-Reply-To: References: <06B12D1D68BCCA4CB1F60BB4EA509768245476@pq-exch01.actional.com> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1967C9F5-1F3C-4AEB-B757-87193EAD5207@fastcrypt.com> Cc: Mike Clements , pgsql-jdbc@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Batch with keygen? Date: Mon, 7 Nov 2005 19:01:04 -0500 To: Kris Jurka X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.022 required=5 tests=[AWL=0.022] X-Spam-Score: 0.022 X-Spam-Level: X-Archive-Number: 200511/44 X-Sequence-Number: 14142 Additionally you should be aware, that using this mechanism once a connection gets a hundred values, they are consumed even if you don't use them. Dave On 7-Nov-05, at 4:18 PM, Kris Jurka wrote: > > > On Mon, 7 Nov 2005, Mike Clements wrote: > >> I've got a bunch of PreparedStatements doing inserts on tables with >> primary keys generated by sequences. For example, insert on table A, >> take generated primary key, insert on table B assigning foreign key >> generated value for A's primary key. >> >> For performance reasons, I need to batch these commands. But I >> don't see >> how it would be possible to continue using this approach with a >> batch of >> commands, because I need the results of the first insert to make the >> second insert. Is there some way to do this or am I going to have to >> stop using keygen and instead have my application generate its own >> keys? >> > > One option would be to tune your sequence generator to your batch > size, consider: CREATE SEQUENCE myseq INCREMENT BY 100; Then if > you fetch a nextval you know that you are also free to use the next > 99 values as well in your batch statement without touching the > sequence. > > Kris Jurka > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: explain analyze is your friend >