Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 606C79FB485 for ; Mon, 22 Jan 2007 01:21:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 38574-10 for ; Mon, 22 Jan 2007 01:21:33 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from www01.kensystem.com (www01.kensystem.com [72.19.170.120]) by postgresql.org (Postfix) with ESMTP id 738EE9FB59A for ; Mon, 22 Jan 2007 01:10:01 -0400 (AST) Received: from 192.168.0.3 by www01.kensystem.com (SMTPD); id s20070122050958.9239; Mon, 22 Jan 2007 05:09:58 Message-ID: <45B44726.1070301@kensystem.com> Date: Sun, 21 Jan 2007 22:09:58 -0700 From: Ken Johanson User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: Dave Cramer CC: Michael Paesold , pgsql-jdbc@postgresql.org Subject: Re: Synthesize support for Statement.getGeneratedKeys()? 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.447 tagged_above=0 required=5 tests=AWL, BAYES_60, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200701/138 X-Sequence-Number: 16503 >> 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