Re: Batch with keygen? - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Batch with keygen?
Date
Msg-id Pine.BSO.4.61.0511071615580.17958@leary.csoft.net
Whole thread Raw
In response to Batch with keygen?  ("Mike Clements" <mclements@actional.com>)
Responses Re: Batch with keygen?  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc

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

pgsql-jdbc by date:

Previous
From: "Mike Clements"
Date:
Subject: Batch with keygen?
Next
From: Dave Cramer
Date:
Subject: Re: Batch with keygen?