Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9952E633B96 for ; Sun, 3 May 2009 13:28:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 64625-09 for ; Sun, 3 May 2009 13:28:55 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f222.google.com (mail-fx0-f222.google.com [209.85.220.222]) by mail.postgresql.org (Postfix) with ESMTP id 0773D633B3F for ; Sun, 3 May 2009 13:28:54 -0300 (ADT) Received: by fxm22 with SMTP id 22so3437711fxm.19 for ; Sun, 03 May 2009 09:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=GWzg+7LwvP2HRNnKFu9oduiTvslT+/5YRHcHS32wylk=; b=eh0x7ZG7boSNHW8LeEh7z8FiK511GUbZ8p+SWteudmpifuqlwzS2eFGDuf79iOvP5h 7f2wEJVH/RPlIpMVar9jHbETiZWbi70gPTJf/f7oijKJMrSJt2q2lauTUHKUZYFS5vSs 5GQcs+mMPWnBaxJyLNJQbPewsvrLGC5JSnD/A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Hr5AbQVb5fVFovBDNB0PBwOkQ7CBAaF3Xff0T+u+Ekp18myIHTZ3jsHtu9U8Q+g3AG IHLWwxpagRpWKHUHji+syDNO3vsb9bbj+Ftk08BiYAXIBdpYOm0vb46x+16C15bkobIC htcNGGUHntIAPdkosOpN7gz5Q9oyZExKZ/Tcw= MIME-Version: 1.0 Received: by 10.239.154.16 with SMTP id b16mr241516hbc.145.1241368133675; Sun, 03 May 2009 09:28:53 -0700 (PDT) In-Reply-To: <491f66a50905030310j5b4cdcd8jbf4f6e757c2ba580@mail.gmail.com> References: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr> <49F71EDD.2070200@opencloud.com> <02437794-A78D-449C-843F-B823195F9623@noopsis.fr> <491f66a50905030310j5b4cdcd8jbf4f6e757c2ba580@mail.gmail.com> Date: Sun, 3 May 2009 18:28:53 +0200 X-Google-Sender-Auth: bb7b77e1777a7228 Message-ID: Subject: Re: Very strange performance decrease when reusing a PreparedStatement From: =?UTF-8?B?UMOpdGVyIEtvdsOhY3M=?= To: Dave Cramer Cc: =?UTF-8?B?RnLDqWTDqXJpayBCaWxoYXV0?= , Oliver Jowett , pgsql-jdbc@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/16 X-Sequence-Number: 19566 On Sun, May 3, 2009 at 12:10 PM, Dave Cramer wrote: > >> It appears that the Postgres "server-prepared statement" cannot handle >> parameters to the statement. This is really unfortunate, because 99% >> of real-life applications will want to re-use the same statement >> (template) with different parameters. >> >> The term "server-prepared statement" itself already indicates that >> there may be something skewed about the "local" semantics of >> java.sql.PreparedStatements in the Postgres JDBC driver. There is no >> notion of "client-prepared statement" in the JDBC API, which conceives >> PreparedStatement instances as mere handles to server side objects. >> And indeed, Postgres JDBC users have historically been using >> java.sql.PreparedStatements for its side-effect of preventing SQL >> injection rather than for the purpose the JDBC API designers had in >> mind with this class. > > I'm not sure where this hypothesis is coming from. Postgresql server > prepared statements can certainly handle parameters. > > What makes you think it can't ? http://jdbc.postgresql.org/documentation/83/server-prepare.html: "Server side prepared statements are planned only once by the server. This avoids the cost of replanning the query every time, but also means that the planner cannot take advantage of the particular parameter values used in a particular execution of the query. You should be cautious about enabling the use of server side prepared statements globally." Or is this only the JDBC perspective of things, meaning that the capability is there at the back-end, just the JDBC driver doesn't take advantage of it? Thanks Peter > > Dave > >