Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 606D49FB53C for ; Thu, 5 Jul 2007 07:19:39 -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 10158-09 for ; Thu, 5 Jul 2007 07:19:28 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by postgresql.org (Postfix) with ESMTP id F0D4F9FB5B1 for ; Thu, 5 Jul 2007 07:19:27 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so502538ugf for ; Thu, 05 Jul 2007 03:19:26 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=BvTmU/883aOAbY9OxJUg3vg6msR53s2PIyQ6cUAOSbhJfaz5ptURcxfeUG1ITnACT8qXlgi9B3O3TsvAvHaImdWspQN4HDZyoamQcgd70CN4OPC4uWYs6MNo1tt9v96FGufLMyywnlBO3SeGYVNBH65ed+S6cawsjG3n2iCS0n0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=RjZ99ZML+5nV/VAmfH0P6ff4PWEyXs4USsro8rm0LqgqEymlmkYwFdJo7Jwc/6wpIoVO6JyHcqQ7/ubX6G1fUjtR7aGV4zrFTK+0+ScZdn2wktML9S8n1veKjenPq3PA2dpb0lMaTFJyG4ctnC0QupOrQQfpUSMv1Esekb73NsM= Received: by 10.67.29.7 with SMTP id g7mr1855197ugj.1183630766303; Thu, 05 Jul 2007 03:19:26 -0700 (PDT) Received: from ?172.24.32.77? ( [62.232.55.118]) by mx.google.com with ESMTPS id 28sm14446ugc.2007.07.05.03.19.23 (version=SSLv3 cipher=RC4-MD5); Thu, 05 Jul 2007 03:19:24 -0700 (PDT) Message-ID: <468CC580.6080207@enterprisedb.com> Date: Thu, 05 Jul 2007 11:18:40 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: Flipper CC: pgsql-jdbc@postgresql.org Subject: Re: prepared statement: are they pre-compiled? References: <200707051023.25650.flipper@gammadue.com> <468CB19F.6080108@enterprisedb.com> <200707051208.59443.flipper@gammadue.com> In-Reply-To: <200707051208.59443.flipper@gammadue.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/19 X-Sequence-Number: 17193 Flipper wrote: > On Thursday 5 July 2007 Heikki Linnakangas's cat, walking on the keyboard, > wrote: >> It depends on the prepareThreshold parameter. The default is 5, which >> means that the query is parsed and planned separately for each call to >> executeQuery, until the 5th call. After that, a generic plan is >> generated and used thereafter. > > Thanks for you explaination! > Where is this default parameter set? I cannot find it. In the connection string, see http://jdbc.postgresql.org/documentation/82/connect.html#connection-parameters. Or you can set it programmatically with PGConnection.setPrepareThreshold. > By the way, I cannot see the real difference in the code, and in fact the > QueryExecutor goes into the sendParse with oneShot = false (since the flag > has not been set). The sendParse creates a statement name and then sends the > parse message. So the doubt is: the parse message is always sent and the > server ignores it when a statement name is provided? Or is something in the > Java code that I'm not getting? I'm not familiar with that code myself either, but at the beginning of sendParse, we check if we've already sent a PARSE for the given query and parameters: > // Already parsed, or we have a Parse pending and the types are right? > int[] typeOIDs = params.getTypeOIDs(); > if (query.isPreparedFor(typeOIDs)) > return; -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com