Skip site navigation (1) Skip section navigation (2)

Re: Prepare Statement

From: Kris Jurka <books(at)ejurka(dot)com>
To: Jie Liang <jie(at)stbernard(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org,pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepare Statement
Date: 2004-06-15 18:00:00
Message-ID: Pine.BSO.4.56.0406151238310.10395@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbcpgsql-sql

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

In response to

pgsql-sql by date

Next:From: Patrick HatcherDate: 2004-06-15 18:55:06
Subject: Is there a faster way to do this?
Previous:From: Jie LiangDate: 2004-06-15 16:44:03
Subject: Re: [SQL] Prepare Statement

pgsql-jdbc by date

Next:From: Dave CramerDate: 2004-06-16 11:54:58
Subject: release soon ?
Previous:From: Kris JurkaDate: 2004-06-15 17:38:26
Subject: Re: cursor "jdbc_curs_1" does not exist

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group