Re: Prepared Statements - Mailing list pgsql-jdbc

From Erik Price
Subject Re: Prepared Statements
Date
Msg-id 3F15BA6D.7070106@ptc.com
Whole thread Raw
In response to Prepared Statements  (Julien Le Goff <julien.legoff@laposte.net>)
List pgsql-jdbc

Julien Le Goff wrote:
> Hello everyone,
>
> I have a question regarding the efficiency of Prepared Statements. I'm
> working on a project, and my task now is to decide whether it's worth
> it to use PS. This problem came up when, beginning to implement jdbc
> classes, we noticed that we would need a lot of PS - something like 40
> per class. Each PS would be a class variable, and it sounds weird to
> have 40 class variables... We could have a more elegant system using
> normal statements, but would it be much less efficient?

My understanding is that the efficiency of a PreparedStatement really
depends on the database.  I have no information about this subject in
reference to PostgreSQL (or any other database), however.

Usually you will want to use a PreparedStatement so that in the case
where a database -does- make use of it and caches the query, it will be
done.  However, you've mentioned that you have an equally performant and
more elegant solution using regular queries.  I'd go with elegance until
you really need the performance.



Erik


pgsql-jdbc by date:

Previous
From: Julien Le Goff
Date:
Subject: Prepared Statements
Next
From: Fernando Nasser
Date:
Subject: Re: Prepared Statements