pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Csaba Nagy <nagy@ecircle-ag.com>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: Postgres JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: PGStatement#setPrepareThreshold
Date: Thu, 3 Aug 2006 13:38:37 -0400
Message-ID: <BD03ACFB-8073-4952-9FA0-8797DABD19D7@fastcrypt.com> (raw)
In-Reply-To: <B4707B92-5F53-44B3-AFE0-F939C3559E51@fastcrypt.com>
References: <1154529173.21451.27.camel@coppola.muc.ecircle.de>
	<44D19215.1070002@opencloud.com>
	<1154596670.21451.44.camel@coppola.muc.ecircle.de>
	<B4707B92-5F53-44B3-AFE0-F939C3559E51@fastcrypt.com>

Ok, further investigation shows that it does work

However I'm still puzzled by these backend logs

<test test>LOG:  statement: PREPARE S_3 AS INSERT INTO texttable (te)  
VALUES ($1)
<test test>LOG:  statement: <BIND>
<test test>LOG:  statement: EXECUTE <unnamed>  [PREPARE:  INSERT INTO  
texttable (te) VALUES ($1)]

We see the prepare to a named statement, but then the execute is  
unnamed ?

Dave

On 3-Aug-06, at 7:53 AM, Dave Cramer wrote:

> Csaba,
>
> Actually I was debugging some other code and noticed that it  
> doesn't really get set, this just confirms my suspicions. I'll try  
> to get something out in a few hours
>
> Dave
> On 3-Aug-06, at 5:17 AM, Csaba Nagy wrote:
>
>> Oliver,
>>
>> Thanks for your answer.
>>
>>> The logic looks like:
>>> - On statement creation set count=0
>>> - On each execution:
>>>    - If this statement is a PreparedStatement, increment count
>>>    - If threshold == 0 or count < threshold, make this execution  
>>> "oneshot"
>>>    - Execute query
>>
>> OK, I've checked the sources. I'm using postgresql-jdbc-8.1dev-400.
>> The relevant piece of code looks to me to be in
>> AbstractJdbc2Statement#execute(Query,ParameterList,int):
>>
>>         // Only use named statements after we hit the threshold
>>         if (preparedQuery != null)
>>         {
>>             ++m_useCount; // We used this statement once more.
>>             if (m_prepareThreshold == 0 || m_useCount <
>> m_prepareThreshold)
>>                 flags |= QueryExecutor.QUERY_ONESHOT;
>>         }
>>
>> So if preparedQuery is not null for prepared statements, it should  
>> work
>> as you said...
>>
>>> "oneshot" queries use the unnamed statement (with one exception:  
>>> queries
>>> that will be backed by a portal use a named statement)
>>>
>>>> I couldn't figure out this from the log files... postgres logs the
>>>> queries as <unnamed>, but that doesn't tell me too much.
>>>
>>> If you're seeing <unnamed> then those queries aren't using server- 
>>> side
>>> prepare (the unnamed statement is also special as it's the  
>>> trigger for
>>> the planner behaviour that you are trying to avoid..) .. so it seems
>>> that you are not managing to trigger server-side prepare for some
>>> reason. Maybe you are using a plain Statement?
>>
>> No, I definitely use a prepared statement, I have lots of  
>> parameters in
>> the IN clause... that's part of the problem. And I checked again,  
>> and it
>> is logged as <unnamed> in the postgres logs.
>>
>> So the only remaining suspect is that the threshold is not really  
>> set to
>> 1. This is somewhat strange, as I use a connection pool and set it  
>> to 1
>> on each connection, and only set it to 0 on specific statements  
>> where I
>> do want the parameter values to be taken into account (I know,  
>> I'll have
>> to change this, but it was the easiest way to get the system stable
>> after switching from Oracle to postgres).
>>
>> I will have to investigate what is the real problem.
>>
>> Thanks,
>> Csaba.
>>
>>
>>
>>
>>
>> ---------------------------(end of  
>> broadcast)---------------------------
>> TIP 2: Don't 'kill -9' the postmaster
>>
>
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>




view thread (28+ messages)  latest in thread

Message-ID: <BD03ACFB-8073-4952-9FA0-8797DABD19D7@fastcrypt.com>
Permalink:  ../BD03ACFB-8073-4952-9FA0-8797DABD19D7@fastcrypt.com/
Also on:    postgresql.org/message-id/BD03ACFB-8073-4952-9FA0-8797DABD19D7@fastcrypt.com

 · 

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: pg@fastcrypt.com, nagy@ecircle-ag.com, oliver@opencloud.com
  Subject: Re: PGStatement#setPrepareThreshold
  In-Reply-To: <BD03ACFB-8073-4952-9FA0-8797DABD19D7@fastcrypt.com>
  References: <1154529173.21451.27.camel@coppola.muc.ecircle.de> <44D19215.1070002@opencloud.com> <1154596670.21451.44.camel@coppola.muc.ecircle.de> <B4707B92-5F53-44B3-AFE0-F939C3559E51@fastcrypt.com> <BD03ACFB-8073-4952-9FA0-8797DABD19D7@fastcrypt.com>

* 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