pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ken Johanson <pg-user@kensystem.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: Michael Paesold <mpaesold@gmx.at>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Date: Sun, 21 Jan 2007 22:09:58 -0700
Message-ID: <45B44726.1070301@kensystem.com> (raw)
In-Reply-To: <B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com>
References: <4580E681.3080106@kensystem.com>
	<45810230.80803@gmx.at>
	<45B1AC19.3090300@kensystem.com>
	<45B1F839.3060402@gmx.at>
	<45B254D7.4080304@kensystem.com>
	<55027648-0777-4BE4-8581-933E86180539@fastcrypt.com>
	<45B3B9CB.3070308@kensystem.com>
	<3C6B3C20-CD94-4D35-B146-27DA78E6E462@fastcrypt.com>
	<45B40AE1.8020003@kensystem.com>
	<B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com>


>> As an aside, how do PG jdbc users get the server generated keys? Or 
>> does everyone use some kind of UUID system (which I think is generally 
>> regarded as detrimental to indexes/memory under high load and large DB 
>> sizes - compared to int/bigint)? Or do PG users using some standard or 
>> server-specific (RETURNING) SQL clause?
> 
> either create the key ahead of time select nextval('sequence') and 
> insert it explicitly, or insert the row and  then  select 
> currval('sequence')
> 


That makes sense; the sequence is retrieved and it internally increments 
- regardless of whether the key was actually inserted or not. I'm 
personally not used to this though, it allows for actual keys in the 
database to possibly have gaps (if the key want actually used / rollback 
etc). Thats trivial / innocuous I guess, but I'm just used to having 
sequential keys tables. Would this require two trips to the server, or 
can we handle in one excecuteUpdate?

My real question is, what about the case where multiple VALUES are 
inserted; if I have 3 values should I call the sequence 3 times? What is 
the most efficient was to do that? (Can I do it in a single query?)

Thank you,
ken





view thread (50+ messages)  latest in thread

Message-ID: <45B44726.1070301@kensystem.com>
Permalink:  ../45B44726.1070301@kensystem.com/
Also on:    postgresql.org/message-id/45B44726.1070301@kensystem.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 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-user@kensystem.com, pg@fastcrypt.com, mpaesold@gmx.at
  Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
  In-Reply-To: <45B44726.1070301@kensystem.com>
  References: <4580E681.3080106@kensystem.com> <45810230.80803@gmx.at> <45B1AC19.3090300@kensystem.com> <45B1F839.3060402@gmx.at> <45B254D7.4080304@kensystem.com> <55027648-0777-4BE4-8581-933E86180539@fastcrypt.com> <45B3B9CB.3070308@kensystem.com> <3C6B3C20-CD94-4D35-B146-27DA78E6E462@fastcrypt.com> <45B40AE1.8020003@kensystem.com> <B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com> <45B44726.1070301@kensystem.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