pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: mljv@planwerk6.de
Cc: pgsql-general@postgresql.org
Subject: Re: Prepared Statements
Date: Sat, 12 Jan 2008 17:04:41 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0801121657280.9136@leary.csoft.net> (raw)
In-Reply-To: <200801101153.38782.mljv@planwerk6.de>
References: <200801092002.15417.mljv@planwerk6.de>
	<Pine.BSO.4.64.0801091507500.27353@leary.csoft.net>
	<200801101153.38782.mljv@planwerk6.de>



On Thu, 10 Jan 2008, mljv@planwerk6.de wrote:

> ah! So it doesn't help if it's the same statement, it has to be the same
> object! So DBCP has a statement pool like a map, say
> Map<String, PreparedStatement>
> so it can fetch the reference to already existing prepared Statement by
> looking at the statement itself, right?

Exactly.

> But JDBC itself uses the "PREPARE" sql command, right?
> So the statement is not really unnamed its name is "<unnamed>" like
> prepare "<unnamed>" as select * from table;
> execute "<unnamed>";
>
> But i can't see any DEALLOCATE statements in my log file.

The JDBC driver does not use SQL level PREPARE / DEALLOCATE calls, but 
instead uses protocol level commands that are pretty much equivalent. 
The logging process tries to log sql and protocol level commands the same 
way which is why it shows up that way in the log.  Perhaps the server 
should log the protocol level deallocate as well?

> What do you mean with "longer lifespan"? Doesn't the JDBC driver uses the
> PREPARE Sql Statement and therefore the prepared Statement has the same
> lifespan as the connection? If so, as connections are pooled and never
> closed, the prepared Statement will last forever. What if the table analyzes
> changes and a better execution plan could be found?
>

Data and stats changes do not trigger a replan.

Kris Jurka



view thread (19+ messages)  latest in thread

Message-ID: <Pine.BSO.4.64.0801121657280.9136@leary.csoft.net>
Permalink:  ../Pine.BSO.4.64.0801121657280.9136@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.64.0801121657280.9136@leary.csoft.net

 · 

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-general@postgresql.org
  Cc: books@ejurka.com, mljv@planwerk6.de
  Subject: Re: Prepared Statements
  In-Reply-To: <Pine.BSO.4.64.0801121657280.9136@leary.csoft.net>
  References: <200801092002.15417.mljv@planwerk6.de> <Pine.BSO.4.64.0801091507500.27353@leary.csoft.net> <200801101153.38782.mljv@planwerk6.de> <Pine.BSO.4.64.0801121657280.9136@leary.csoft.net>

* 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