Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 1EC722E0310 for ; Wed, 13 Feb 2008 14:51:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 81943-01 for ; Wed, 13 Feb 2008 14:51:26 -0400 (AST) Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 546A42E0305 for ; Wed, 13 Feb 2008 14:51:26 -0400 (AST) Received: (qmail 27181 invoked by uid 1112); 13 Feb 2008 18:51:24 -0000 Date: Wed, 13 Feb 2008 13:51:24 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Josh Berkus cc: PostgreSQL - JDBC Subject: Re: JDBC, prepared queries, and partitioning In-Reply-To: <200802131005.30553.josh@agliodbs.com> Message-ID: References: <200802131005.30553.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/51 X-Sequence-Number: 18258 On Wed, 13 Feb 2008, Josh Berkus wrote: > Since JDBC always prepares and plan-caches queries, it makes it hard to use > partitioning with a database connected to a JDBC connection pool; successive > queries in the same session will select the wrong partition, or scan the > whole partition set. > It will never scan the wrong partition. It will always scan all partitions. The server is smart enough to not generate a plan that is not valid for only one parameter set. Using protocol version 2 will not prepare queries so constraint exclusion can be used. Just append protocolVersion=2 to your URL. Kris Jurka