X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7E50C3A543F for ; Tue, 30 Nov 2004 18:26:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30029-09 for ; Tue, 30 Nov 2004 18:25:36 +0000 (GMT) Received: from cougar.DIT.UMontreal.CA (chene.DIT.UMontreal.CA [132.204.246.20]) by svr1.postgresql.org (Postfix) with ESMTP id 5374C3A553F for ; Tue, 30 Nov 2004 18:06:38 +0000 (GMT) Received: from chene.dit.umontreal.ca(132.204.246.20) by cougar.DIT.UMontreal.CA via csmap id 94b586b2_42fa_11d9_99b0_0002b39fa8dc_8112; Tue, 30 Nov 2004 13:06:40 -0500 (EST) Received: from cougar.DIT.UMontreal.CA (gw-mail.LEXUM.UMontreal.CA [132.204.136.52]) by chene.DIT.UMontreal.CA (8.13.1/8.13.1) with ESMTP id iAUI6Y14032301 for ; Tue, 30 Nov 2004 13:06:34 -0500 Received: from gw-mail.lexum.umontreal.ca(132.204.136.52) by cougar.DIT.UMontreal.CA via csmap id 91e62432_42fa_11d9_99fb_0002b39fa8dc_8083; Tue, 30 Nov 2004 13:06:34 -0500 (EST) Received: from [192.168.1.101] ([::ffff:70.80.14.117]) (AUTH: PLAIN paree, SSL: TLSv1/SSLv3,256bits,AES256-SHA) by mail.lexum.umontreal.ca with esmtp; Tue, 30 Nov 2004 13:04:25 -0500 id 00013879.41ACB629.00007B24 Subject: Re: Need a performance tip - Statement pooling for server From: "=?ISO-8859-1?Q?=C9ric_Par=E9?=" Reply-To: paree@LEXUM.UMontreal.CA To: Xavier Poinsard Cc: pgsql-jdbc@postgresql.org In-Reply-To: References: Organization: LexUM Message-Id: <1101837968.3329.12.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_roma.dmz.lexum.pri-31528-1101837866-0001-2" X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 30 Nov 2004 13:06:09 -0500 X-NAI-Spam-Score: 0.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM X-Spam-Level: * X-Archive-Number: 200411/243 X-Sequence-Number: 11665 This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_roma.dmz.lexum.pri-31528-1101837866-0001-2 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Mime-Autoconverted: from 8bit to quoted-printable by courier 0.47 I apologize for this psycho remark, but I always feel afraid of seeing re-use of PreparedStatement objects without calling the clearParameters() function that resets all parameters... Just thought It might be worth mentionning. -- =C9ric Par=E9 for/pour LexUM Universit=E9 de Montr=E9al Centre de recherche en droit public C.P. 6128, succ. Centre-ville Montr=E9al (Qc) Canada H3C 3J7 +1 514-343-6111 #0873 paree@lexum.umontreal.ca --=_roma.dmz.lexum.pri-31528-1101837866-0001-2 Content-Type: message/rfc822 Content-Disposition: inline Content-Description: Forwarded message - Re: [JDBC] Need a performance tip - Statement pooling for server Delivered-To: paree@lexum.umontreal.ca Return-Path: Received: from puma.DIT.UMontreal.CA ([::ffff:132.204.246.26]) by mail.lexum.umontreal.ca with esmtp; Tue, 30 Nov 2004 11:56:21 -0500 id 0001387C.41ACA635.000070D8 Received: from platane.dit.umontreal.ca(132.204.246.26) by puma.DIT.UMontreal.CA via csmap id 0ab9a42e_42f1_11d9_8551_0002b3da0f4e_10022; Tue, 30 Nov 2004 11:58:29 -0500 (EST) Received: from puma.DIT.UMontreal.CA (svr4.postgresql.org [66.98.251.159]) by platane.DIT.UMontreal.CA (8.13.1/8.13.1) with ESMTP id iAUGwJQq008797 for ; Tue, 30 Nov 2004 11:58:20 -0500 Received: from svr4.postgresql.org(66.98.251.159) by puma.DIT.UMontreal.CA via csmap id 093ce9bc_42f1_11d9_95c4_0002b3da0f4e_9887; Tue, 30 Nov 2004 11:58:20 -0500 (EST) Received: from postgresql.org (svr1.postgresql.org [200.46.204.71]) by svr4.postgresql.org (Postfix) with ESMTP id A58305AF3D9; Tue, 30 Nov 2004 16:58:16 +0000 (GMT) X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DEA143A5235 for ; Tue, 30 Nov 2004 16:56:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97655-07 for ; Tue, 30 Nov 2004 16:56:34 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) by svr1.postgresql.org (Postfix) with ESMTP id 90F223A45C5 for ; Tue, 30 Nov 2004 16:56:34 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 9A40A31922; Tue, 30 Nov 2004 17:56:33 +0100 (MET) From: Xavier Poinsard X-Newsgroups: pgsql.interfaces.jdbc Subject: Re: [JDBC] Need a performance tip - Statement pooling for server Date: Tue, 30 Nov 2004 17:56:35 +0100 Organization: PYRENET Midi-pyrenees Provider Lines: 131 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 X-Accept-Language: fr-fr, en-us, en In-Reply-To: To: pgsql-jdbc@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org X-NAI-Spam-Score: 0.0 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on mail.lexum.umontreal.ca X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=ham version=3.0.1 VIDAL Cedric wrote: > >>-----Message d'origine----- >>De : pgsql-jdbc-owner@postgresql.org >>[mailto:pgsql-jdbc-owner@postgresql.org]De la part de Kris Jurka >>Envoye : mardi 30 novembre 2004 12:37 >>A : VIDAL Cedric >>Cc : 'pgsql-jdbc@postgresql.org' >>Objet : Re: [JDBC] Need a performance tip - Statement pooling >>for server >> >> >> >> >>On Tue, 30 Nov 2004, VIDAL Cedric wrote: >> >> >>>Hi, >>> >>>On the postgresql jdbc site's todo >> >>http://jdbc.postgresql.org/todo.html, it >> >>>is stated that >>>"statement pooling to take advantage of server prepared >> >>statements" should >> >>>be added. >>> >>>Is that information up to date ? Is that feature really not >> >>supported. If >> >>>yes, does that mean, that using JDBC PreparedStatement(s) >> >>with PostgreSQL >> >>>doesn't take avantage of server side statement pooling, and >> >>thus has no >> >>>advantage over simple statements. >>> >> >>There is a difference between not using server side >>statements and not >>pooling them. Consider a function that did an insert into >>the database. >> >>public void f(Connection conn, int i) throws SQLException { >> PreparedStatement ps = conn.prepareStatement("INSERT INTO t >>VALUES(?)"); >> ps.setInt(1,i); >> ps.executeUpdate(); >> ps.close(); >>} >> >>In this case a prepared statement is created every time the >>function is >>called so no real advantage comes from doing a server side >>preparation. >>Now if the function was written as: >> >>public void f(PreparedStatement ps, int i) throws SQLException { >> ps.setInt(1, i); >> ps.executeUpdate(); >>} >> >>Then the prepared statement gets reused and potentially >>significant gains >>can be had from doing server side preparation. The idea >>behind statement >>pooling is to allow a function written in the first form to get the >>performance advantages of a function written in the second >>form. It can >>be difficult to create and manage a pool of >>PreparedStatements to reuse in >>your application code, so it would be great if the driver >>could do that >>for you. >> >>Kris Jurka > > > Hi Kris, > > So if I get it right, i understand that > - 1 - postgresql knows how to prepare statements > - 2 - the pooling is the responsibility of the jdbc driver > - 3 - the postgresql jdbc driver doesn't implement prepared statements > pooling thus does not take advantage of > postgresql's preparing statements (your first form doesn't get the > performance advantage) You take advantage of it when you reuse the same prepared statement. For example : PreparedStatement ps = conn.prepareStatement("INSERT INTO t VALUES(?)"); for (int i=1;i<=5;i++){ ps.setInt(1,i); ps.executeUpdate(); } ps.close(); Or better using batch : PreparedStatement ps = conn.prepareStatement("INSERT INTO t VALUES(?)"); for (int i=1;i<=5;i++){ ps.setInt(1,i); ps.addBatch(); } ps.executeBatch(); ps.close(); > - 4 - if our application were to deal with prepared statements' pooling > itself (your second form), it would get the performance advantage of > postgresql's preparing statements > > Is it so ? > > thanx for the reply, > > Cedric Vidal > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) --=_roma.dmz.lexum.pri-31528-1101837866-0001-2--