pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Radosław Smogura <rsmogura@softperience.eu>
To: pgsql-jdbc@postgresql.org
Cc: louis <louis@ibms.sinica.edu.tw>
Cc: Oliver Jowett <oliver@opencloud.com>
Subject: Re: The logic behind the prepared statement in PostgreSQL
Date: Fri, 8 Oct 2010 11:12:37 +0200
Message-ID: <201010081112.37192.rsmogura@softperience.eu> (raw)
In-Reply-To: <1286430904.7465.4.camel@london>
References: <1286365302.13691.35.camel@london>
	<4CACE716.5010600@opencloud.com>
	<1286430904.7465.4.camel@london>

Hi,

> I think it's because postgresql JDBC Driver has a default limit for the max
> number of preparedStatement, which is 4. Can anyone tell me where to
> adjuest this parameter?

This parameter 4 is associated with prepare threshold. It says how many times 
the given prepared statement (as Java object) will be executed before it will 
be compiled into true, server side prepared statement.

In many applications developers uses PreparedStatement class just to wrap 
parameters, so compiling such statement in server side statement adds unneeded 
overhead. After you execute such PS few times then it's compiled, and in logs 
you will see EXECUTE S_1 or S_1/C_1.

PG JDBC driver doesn't have built in support for caching statements in any 
way, so two statements with same SQL will be mapped to different statements in 
database, even if that are called in scope of same connection.

If you would like to cache statements, currently most servers support this, by 
wrapping original database objects.

Kind ragards,
Radosław Smogura
http://www.softperience.eu



view thread (8+ messages)

Message-ID: <201010081112.37192.rsmogura@softperience.eu>
Permalink:  ../201010081112.37192.rsmogura@softperience.eu/
Also on:    postgresql.org/message-id/201010081112.37192.rsmogura@softperience.eu

 · 

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: rsmogura@softperience.eu, louis@ibms.sinica.edu.tw, oliver@opencloud.com
  Subject: Re: The logic behind the prepared statement in PostgreSQL
  In-Reply-To: <201010081112.37192.rsmogura@softperience.eu>
  References: <1286365302.13691.35.camel@london> <4CACE716.5010600@opencloud.com> <1286430904.7465.4.camel@london> <201010081112.37192.rsmogura@softperience.eu>

* 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