Re: Prepared Statements

From: Erik Price <eprice(at)ptc(dot)com>
To: Julien Le Goff <julien(dot)legoff(at)laposte(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepared Statements
Date: 2003-07-16 20:49:49
Message-ID: 3F15BA6D.7070106@ptc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Fernando Nasser 2003-07-16 21:21:03 Re: Prepared Statements
Previous Message Julien Le Goff 2003-07-16 20:24:37 Prepared Statements