Re: Prepared Statements

From: "Isak Hansen" <isak(dot)hansen(at)gmail(dot)com>
To: "mljv(at)planwerk6(dot)de" <mljv(at)planwerk6(dot)de>
Cc: "Kris Jurka" <books(at)ejurka(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Prepared Statements
Date: 2008-01-10 12:12:03
Message-ID: 6b9e1eb20801100412w6f951dd6y9de1e39a0c5805a8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/10/08, mljv(at)planwerk6(dot)de <mljv(at)planwerk6(dot)de> wrote:
> > >
> > > I have not found anything about preparing "unnamed" statements. What
> > > does it mean?
> >
> > Unnamed statements are what the driver uses before it hits the
> > prepareThreshold limit. Once it has determined the statement will be
> > reused many times it changes to a named statement that has a longer
> > lifespan.
>
> 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?
>

An unnamed prepared query is just a normal one-shot query, but it
allows the use of bind variables.

You'll find more details in the protocol section of the postgres docs
<http://www.postgresql.org/docs/8.3/static/protocol.html>.

Regards,
Isak

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Schwarzer 2008-01-10 12:23:54 Re: Installation problem: failed to initialize lc_messages to ""
Previous Message Sebastián Baioni 2008-01-10 12:04:14 Re: Can't make backup