From: Dave Cramer <pg@fastcrypt.com>
To: Kris Jurka <books@ejurka.com>
Cc: Mike Clements <mclements@actional.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Batch with keygen?
Date: Mon, 7 Nov 2005 19:01:04 -0500
Message-ID: <1967C9F5-1F3C-4AEB-B757-87193EAD5207@fastcrypt.com> (raw)
In-Reply-To: <Pine.BSO.4.61.0511071615580.17958@leary.csoft.net>
References: <06B12D1D68BCCA4CB1F60BB4EA509768245476@pq-exch01.actional.com>
<Pine.BSO.4.61.0511071615580.17958@leary.csoft.net>
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
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg@fastcrypt.com, books@ejurka.com, mclements@actional.com
Subject: Re: Batch with keygen?
In-Reply-To: <1967C9F5-1F3C-4AEB-B757-87193EAD5207@fastcrypt.com>
References: <06B12D1D68BCCA4CB1F60BB4EA509768245476@pq-exch01.actional.com> <Pine.BSO.4.61.0511071615580.17958@leary.csoft.net> <1967C9F5-1F3C-4AEB-B757-87193EAD5207@fastcrypt.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