X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4C62CD1B215 for ; Tue, 15 Jun 2004 15:00:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11070-04 for ; Tue, 15 Jun 2004 18:00:04 +0000 (GMT) Received: from mail63.csoft.net (unknown [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 9D829D1B1D9 for ; Tue, 15 Jun 2004 14:59:59 -0300 (ADT) Received: (qmail 10250 invoked by uid 1112); 15 Jun 2004 18:00:00 -0000 Date: Tue, 15 Jun 2004 13:00:00 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Jie Liang Cc: Tom Lane , pgsql-sql@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: Prepare Statement In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/57 X-Sequence-Number: 10259 On Mon, 14 Jun 2004, Jie Liang wrote: > I have a question about performance, in SQL commands: there is a > prepare/execute command, document says it will improve the performance > while repeatly execute a statement. In java.sql: there is a > PreparedStatement object, which can store precompiled SQL statement, > document says it can improve the performance also. > If I use java jdbc to connect postgresql database, which one I should > use? Can I use both? > When using JDBC it is best to use the standard Statement/PreparedStatement interfaces. It is possible to directly use PREPARE/EXECUTE, but this can be handled by the driver. Let me give you a run down of the different driver versions and their capabilities: Current released version: can enable using PREPARE/EXECUTE behind the scenes on PreparedStatement by casting the prepared statement to PGStatement and issuing setUseServerPrepare. Current cvs version: can enable using PREPARE/EXECUTE by setting an execution threshold that will turn it on when reached. This threshold can be set at a number of levels, see the following for more information http://www.ejurka.com/pgsql/docs/cvs/ch09s05.html Soon to be committed cvs version: can directly use server prepared statements without using the SQL level PREPARE/EXECUTE. Kris Jurka