Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C1E7215B5F4 for ; Wed, 16 Nov 2011 17:17:21 -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 66568-06 for ; Wed, 16 Nov 2011 21:17:15 +0000 (UTC) Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 462E315B5F3 for ; Wed, 16 Nov 2011 17:17:14 -0400 (AST) Received: from mail63.csoft.net ([205.205.214.4]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RQmr3-0000Ua-5X for pgsql-jdbc@postgresql.org; Wed, 16 Nov 2011 21:17:14 +0000 Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 0A41B284D9; Wed, 16 Nov 2011 16:17:00 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=tGILACpIiH1IVbS7UPi4WAr4e+g=; b=xKZxOZ Axl+9YcoQJV8CyGxJI8YuvyC+6K0kmQz5bHpmO7bJvixS9+kLaQzoz00OA5rbNzt 6AL6qtUWTXiWmYq19GIkaH/bT+Kzv9nAB6WairTBiSL61xfgcj/3PT/gk6XXRP0N zE4Z/2H7hWC6NSzLoFFDRFtlgWGNQ/ygDLspk= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 00E66284D7; Wed, 16 Nov 2011 16:17:00 -0500 (EST) Received: by leary.csoft.net (Postfix, from userid 1112) id DB711A188; Wed, 16 Nov 2011 16:16:59 -0500 (EST) Date: Wed, 16 Nov 2011 16:16:59 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Maciek Sakrejda cc: Anish Kejariwal , "pgsql-jdbc@postgresql.org" Subject: Re: avoid prepared statements on complex queries? In-Reply-To: Message-ID: References: <1321406281.74175.YahooMailNeo@web33903.mail.mud.yahoo.com> <1321475873.74818.YahooMailNeo@web33905.mail.mud.yahoo.com> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201111/30 X-Sequence-Number: 22365 On Wed, 16 Nov 2011, Maciek Sakrejda wrote: > Maybe, although I've never seen that happen and as I understand, the > driver always sends parameters along with the statement when using > unnamed statements, so I'm not sure what would trigger this. The standard example is "WHERE col LIKE ?". If the parameter is something like 'abcdef%' then the query can potentially be converted to a range scan, but only if knows the parameter value. When preparing this with an unnamed statement the server has the parameter value, but cannot assume that the same unnamed statement won't be used with a different parameter value later and must come up with a plan that is correct for all possible parameters even if it's not ideal for the current one. Kris Jurka