Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 2A77E2E006E for ; Wed, 20 Feb 2008 10:27:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 63483-01 for ; Wed, 20 Feb 2008 10:27:02 -0400 (AST) Received: from mail01.enterprisedb.com (webmail.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id 457642E005C for ; Wed, 20 Feb 2008 10:27:10 -0400 (AST) thread-index: AchzzMDe0V9KoyHESbCoA8oryo8TPA== Received: from [192.168.1.33] ([81.109.253.218]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 20 Feb 2008 09:27:42 -0500 Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Message-ID: <47BC387D.60008@enterprisedb.com> Date: Wed, 20 Feb 2008 14:26:05 +0000 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: "Paul Tomblin" Cc: Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ? References: <38245.1203500677@motionsponsor.com> <47BC0AF6.2060500@enterprisedb.com> <87prurrh87.fsf@mnc.ch> <55C92F71-0317-4E91-A092-C22A7A2F1FD8@fastcrypt.com> <47BC1AC4.5010809@gmail.com> <9096E930-A528-4AF7-92B9-6EB1A5A52F84@fastcrypt.com> <47BC2798.9010300@enterprisedb.com> <8efd35820802200536n22c75f92u97474ab4d3a9cdee@mail.gmail.com> <47BC300E.1030507@enterprisedb.com> <8efd35820802200603p1d27c66dk1105608ac1495f5@mail.gmail.com> In-Reply-To: <8efd35820802200603p1d27c66dk1105608ac1495f5@mail.gmail.com> Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Feb 2008 14:27:42.0531 (UTC) FILETIME=[C0CE0930:01C873CC] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/171 X-Sequence-Number: 18378 Paul Tomblin wrote: > Be that as it may, I still don't see what you gain by doing > insert ... (nextval('idseq'),... > select currval('idseq'); > when you could do > select nextval('idseq'); > insert ...(?,... Oh, sure, there's not gain either way. Select nextval + insert works just as well. Theoretically, you could "pipeline" the "INSERT nextval" + "SELECT currval" method, by sending both commands at once and only then block and wait for response, saving one round-trip to the server. You could do that with a batch statement, I think, or by single executeQuery("INSERT ... ; SELECT currval(...)"). But if you don't do that, there's no difference. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com