Re: prepared statement: are they pre-compiled?

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Flipper <flipper(at)gammadue(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: prepared statement: are they pre-compiled?
Date: 2007-07-05 10:18:40
Message-ID: 468CC580.6080207@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Flipper wrote:
> On Thursday 5 July 2007 Heikki Linnakangas's cat, walking on the keyboard,
> wrote:
>> It depends on the prepareThreshold parameter. The default is 5, which
>> means that the query is parsed and planned separately for each call to
>> executeQuery, until the 5th call. After that, a generic plan is
>> generated and used thereafter.
>
> Thanks for you explaination!
> Where is this default parameter set? I cannot find it.

In the connection string, see
http://jdbc.postgresql.org/documentation/82/connect.html#connection-parameters.

Or you can set it programmatically with PGConnection.setPrepareThreshold.

> By the way, I cannot see the real difference in the code, and in fact the
> QueryExecutor goes into the sendParse with oneShot = false (since the flag
> has not been set). The sendParse creates a statement name and then sends the
> parse message. So the doubt is: the parse message is always sent and the
> server ignores it when a statement name is provided? Or is something in the
> Java code that I'm not getting?

I'm not familiar with that code myself either, but at the beginning of
sendParse, we check if we've already sent a PARSE for the given query
and parameters:

> // Already parsed, or we have a Parse pending and the types are right?
> int[] typeOIDs = params.getTypeOIDs();
> if (query.isPreparedFor(typeOIDs))
> return;

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Heikki Linnakangas 2007-07-05 12:24:32 Re: prepared statement: are they pre-compiled?
Previous Message Flipper 2007-07-05 10:08:59 Re: prepared statement: are they pre-compiled?