Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id E0EC49FBBE8 for ; Tue, 26 Jun 2007 05:22:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 23965-07-4 for ; Tue, 26 Jun 2007 05:22:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail3.ecircle.de (mail3.ecircle.de [195.140.186.206]) by postgresql.org (Postfix) with ESMTP id B80A29FB550 for ; Tue, 26 Jun 2007 05:22:28 -0300 (ADT) Received: from einstein.muc.ecircle.de (einstein.muc.ecircle.de [192.168.1.7]) by mail3.ecircle.de (READY) with ESMTP id E710811C060; Tue, 26 Jun 2007 10:22:25 +0200 (CEST) Received: from [192.168.1.91] ([192.168.1.91]) by einstein.muc.ecircle.de with Microsoft SMTPSVC(6.0.3790.1830); Tue, 26 Jun 2007 10:22:25 +0200 Subject: Re: Prepared statements, parameters and logging From: Csaba Nagy To: Oliver Jowett Cc: Dave Cramer , Postgres JDBC In-Reply-To: <46803664.3060701@opencloud.com> References: <1182768449.13328.60.camel@coppola.muc.ecircle.de> <6A182763-97EC-43C9-BD13-EE5375A83AC2@fastcrypt.com> <1182770018.13328.63.camel@coppola.muc.ecircle.de> <1182775348.13328.69.camel@coppola.muc.ecircle.de> <9537AA08-53BB-434E-9E62-F326AADED792@fastcrypt.com> <1182778475.13328.79.camel@coppola.muc.ecircle.de> <46803664.3060701@opencloud.com> Content-Type: text/plain Message-Id: <1182846145.13328.95.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 26 Jun 2007 10:22:25 +0200 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 Jun 2007 08:22:25.0295 (UTC) FILETIME=[2062F9F0:01C7B7CB] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/101 X-Sequence-Number: 17163 On Mon, 2007-06-25 at 23:40, Oliver Jowett wrote: > I believe that's logging execution of an unnamed portal, not an unnamed > statement. I'm not sure whether the current server logging actually lets > you tell whether a named statement was used/reused or not (at least that > was one of my complaints about early versions of it -- haven't checked > what current versions do). > > If the statement name is logged, it'd be something like "S_12345". Thanks Oliver for your answer. My real question is: am I turning the right knob with "prepareThreshold=0" ? I want all queries to be planned taking into account the parameter values by default. I can turn this off on special cases by setting the prepare threashold on the statement level - if the prepareThreshold is affecting at all the fact that parameters are sent for planning or not... is it ? I was supposing it is, but I could not figure it out from the logging - and the results in query execution time seem to contradict what I get by explain on a PREPARE (which suck the same as my production system) vs. on direct sql with parameters included (which seems to yield the correct plan). The actual case is a query including a table which has one id value which has very skewed cardinality compared to the average, and the generic plan sucks badly for this one id. Thanks, Csaba.