Re: The logic behind the prepared statement in PostgreSQL - Mailing list pgsql-jdbc

From Radosław Smogura
Subject Re: The logic behind the prepared statement in PostgreSQL
Date
Msg-id 201010081110.16571.rsmogura@softperience.eu
Whole thread Raw
In response to Re: The logic behind the prepared statement in PostgreSQL  (louis <louis@ibms.sinica.edu.tw>)
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: danap
Date:
Subject: DatabaseMetaData.getTablePrivileges()
Next
From: Radosław Smogura
Date:
Subject: Re: The logic behind the prepared statement in PostgreSQL