Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 27FF81337B81 for ; Fri, 25 Feb 2011 05:52:11 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 47622-10 for ; Fri, 25 Feb 2011 09:52:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by mail.postgresql.org (Postfix) with ESMTP id 170381337B4F for ; Fri, 25 Feb 2011 05:52:02 -0400 (AST) Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p1P9q1Nh031905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Feb 2011 10:52:02 +0100 Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p1P9q0tJ016330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Feb 2011 10:52:00 +0100 Received: from [129.206.91.36] (IMSM3.zbt.uni-heidelberg.de [129.206.91.36]) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id p1P9q0KL012790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Feb 2011 10:52:00 +0100 Message-ID: <4D677BBC.8030905@uni-heidelberg.de> Date: Fri, 25 Feb 2011 10:51:56 +0100 From: Lars Feistner User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: difference on execution time between prepared statement in pgAdmin and through JDBC Stack References: <4D66766B.30104@justis.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/151 X-Sequence-Number: 21549 Hello Maciek, okay, thanx for the clarifcation. Here are the server side logs for the pgAdmin case: 2011-02-25 10:42:08 CET LOG: duration: 98.226 ms statement: execute t2 (1,7429); 2011-02-25 10:42:08 CET DETAIL: prepare: prepare t2 (int4, int4) AS SELECT DISTINCT vec.*, s.statistic_difficulty as examination_difficulty, s.statistic_discriminatorypower as examination_discriminatorypower, vimc.mediacount,vis.difficulty, vis.discriminatorypower, vis.statistic_counter, virc.reviewcount, u.user_surname FROM ims_vexaminationcontent vec LEFT OUTER JOIN ims_statistic s ON vec.item_id = s.object_id AND s.examination_id = vec.examination_id LEFT OUTER JOIN ims_vitemmediacount vimc ON (vimc.item_id = vec.item_id) LEFT OUTER JOIN ims_vitemstatistic vis ON (vis.item_id = vec.item_id) INNER JOIN ims_user u on (author_id = u.user_id) LEFT OUTER JOIN ims_vitemreviewcount virc ON virc.item_id = vec.item_id WHERE ((vec.examinationcontentversion_version=$1 AND vec.examination_entityid=$2)) ORDER BY vec.examinationcontentversion_sequenceno ASC NULLS LAST Is there a chance to get the execution plan of the statement, when the statement is executed through JDBC stack? I have the same feeling about the edge case here, that is exactly why i am writing to this list;-) So still the question is how can i find out what is going on? Yesterday i also looked at the debug level logs of the jdbc driver but i found nothinng unusal. Any more hints? Thanx in advance Lars On 02/24/2011 07:38 PM, Maciek Sakrejda wrote: > A named prepared statement (which you seem to be using through > pgAdmin) is *not* the same thing as a PreparedStatement in JDBC. Most > pertinently, JDBC is using an unnamed portal to execute the query, > which delays planning until the parameters are provided. I don't think > this ever happens with a named prepared statement (it would help if > you provided server-side logs for the pgAdmin execution as well). The > deferred planning behavior typically works to your advantage, but you > may have run into some edge case here. > > Alternately, because the unnamed portal execution actually also does > the planning, I presume it's counted in the time of the statement > execution, whereas in the pgAdmin case, it looks like you're only > timing the execute, which is going against an already-planned (at > prepare time) query, so you may be comparing apples to oranges. > > --- > Maciek Sakrejda | System Architect | Truviso > > 1065 E. Hillsdale Blvd., Suite 215 > Foster City, CA 94404 > (650) 242-3500 Main > www.truviso.com > -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lars Feistner Kompetenzzentrum für Prüfungen in der Medizin Medizinische Fakultät Heidelberg, Im Neuenheimer Feld 346, Raum 013 69120 Heidelberg E-Mail: feistner@uni-heidelberg.de Fon: +49-6221-56-8269 Fax: +49-6221-56-7175 WWW: http://www.ims-m.de http://www.kompmed.de ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~