pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marc Herbert <Marc.Herbert@continuent.com>
To: pgsql-jdbc@postgresql.org
Subject: "prepared" statements (Re: Limit vs setMaxRows issue)
Date: Thu, 20 Jul 2006 20:52:49 +0200
Message-ID: <khj64hshzwe.fsf_-_@meije.emic.fr> (raw)
References: <44990D57.9070506@sebster.com>
	<Pine.BSO.4.63.0606211055020.7242@leary2.csoft.net>
	<34158.216.41.12.254.1150906222.squirrel@webmail.webopticon.org>
	<11362.1150908394@sss.pgh.pa.us>
	<khjd5cd4zcm.fsf@meije.emic.fr>
	<44B34751.7010704@opencloud.com>
	<khjr70szd30.fsf@meije.emic.fr>
	<44B38164.1040606@opencloud.com>
	<khjsll8xrr1.fsf@meije.emic.fr>
	<44B4823B.6010909@opencloud.com>

Oliver Jowett <oliver@opencloud.com> writes:

> I am a bit confused about what this discussion is actually about .. do
> you have a point to make here? What is it that you want to do that the
> current driver doesn't do well? A fair amount of work has gone into
> getting query execution working smoothly and efficiently within the
> constraints of the API already.. Vague high-level handwaving,
> especially without a clear target, doesn't get us anywhere. For
> example, it's largely irrelevant to an application whether the query
> gets parsed by the server at statement creation or statement execution
> .. at worst, it means you see parse errors at a different point.


- By the way:

<http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html#getMetaData();

  Retrieves a ResultSetMetaData object that contains information about
  the columns of the ResultSet object that will be returned when this
  PreparedStatement object is executed.

  Because a PreparedStatement object is precompiled, it is possible to
  know about the ResultSet object that it will return without having to
  execute it. Consequently, it is possible to invoke the method
  getMetaData on a PreparedStatement object rather than waiting to
  execute it and then invoking the ResultSet.getMetaData method on the
  ResultSet object that is returned.

Similar thing for #getParameterMetadata()


- However, in the 3rd edition of the JDBC book:

  23.1.3 Using parameter metadata wisely

  The purpose of a prepared statement is to allow the data source to
  "prepare" an SQL statement, that is, to compile an SQL statement
  before it is executed. [..] However, not all data sources prepare a
  statement the same way, and some do not prepare them at all. If a
  data source does not precompile SQL statements, the
  ParameterMetaData methods will not be able to return results until
  execution [this is a lie because it misses "lazy" implementations,
  see below].


According to my (limited) understanding of the code, pgjdbc sends a
special "describe" request to the server for #getMetadata() in case the
statement has not been executed yet, and systematically for
#getParameterMetadata().  Neither one seems to cache results, at least
not on the driver-side.


As you said above, all this looks very well-crafted to be functionally
irrelevant to the application. It definitely looks relevant and good
to know concerning performance.





Message-ID: <khj64hshzwe.fsf_-_@meije.emic.fr>
Permalink:  ../khj64hshzwe.fsf_-_@meije.emic.fr/
Also on:    postgresql.org/message-id/khj64hshzwe.fsf_-_@meije.emic.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Marc.Herbert@continuent.com
  Subject: Re: "prepared" statements (Re: Limit vs setMaxRows issue)
  In-Reply-To: <khj64hshzwe.fsf_-_@meije.emic.fr>
  References: <44990D57.9070506@sebster.com> <Pine.BSO.4.63.0606211055020.7242@leary2.csoft.net> <34158.216.41.12.254.1150906222.squirrel@webmail.webopticon.org> <11362.1150908394@sss.pgh.pa.us> <khjd5cd4zcm.fsf@meije.emic.fr> <44B34751.7010704@opencloud.com> <khjr70szd30.fsf@meije.emic.fr> <44B38164.1040606@opencloud.com> <khjsll8xrr1.fsf@meije.emic.fr> <44B4823B.6010909@opencloud.com> <khj64hshzwe.fsf_-_@meije.emic.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox