Re: [JDBC] Prepared statement performance...

From: Barry Lind <barry(at)xythos(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: Peter Kovacs <peter(dot)kovacs(at)sysdata(dot)siemens(dot)hu>, pgsql-general(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Prepared statement performance...
Date: 2002-09-27 20:04:55
Message-ID: 3D94B9E7.7060903@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Dmitry Tkach wrote:
>
> BTW, here is a quote from JDBC javadoc:
>
> * An object that represents a precompiled SQL statement.
> * <P>A SQL statement is precompiled and stored in a
> * <code>PreparedStatement</code> object. This object can then be used to
> * efficiently execute this statement multiple times.
>
> I read 'precompiled' as something more than 'parsed for question marks' :-)
> And also note the phrase about being able to 'efficiently execute this
> statement multiple times'...
>

I don't read more into this than simply parsing question marks. It is
all going to depend on the capabilities of the server. To the extent
the server has additional features that can be leveraged to improve the
performance those should be used. Up until 7.3 of postgres no such
features existed. Now they do and we are exploring how to best take
advantage of them. But it doesn't make sense to use a specific server
feature if it doesn't improve performance in the general case. The
testing I have done so far indicates that using the current
implementation of server side prepared statements doesn't help
performance in the general case and may hinder it. I am reluctant to
make a non-backwardly compatible change in the driver until more data
points come in that there are significant performance improvements
possible without decreasing performance in the general case.

> It seems quite clear to me that it states the intent behind having this
> interface to provide the ability for the users to
> parse a query once and be able to execute it again and again...
> As for the set*() functions, PreparedStatement without them would be of
> very limited use (how often would we need to execute
> *the same exact query* multiple times???), and that's the reason it has
> them, *not* to abstract from the database data representation format...
>

I have many statements that don't take any arguments and that do get
executed multiple times. It all depends on the nature of the application.

thanks,
--Barry

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lamar Owen 2002-09-27 20:15:31 Re: 7.0 -> 7.2 Migration (oops)
Previous Message Jean-Luc Lachance 2002-09-27 19:32:41 Re: cache state reset

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2002-09-27 20:17:12 Re: [JDBC] Prepared statement performance...
Previous Message Barry Lind 2002-09-27 19:29:00 Re: [JDBC] Prepared statement performance...