From: | Mark Lewis <mark(dot)lewis(at)mir3(dot)com> |
---|---|
To: | Hector Rosas <jeziel(dot)rosas(at)gmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: About Connections and PreparedStatements |
Date: | 2005-10-12 20:01:04 |
Message-ID: | 1129147265.3999.3.camel@archimedes |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
If you need to execute the same query many times, then keep the
preparedStatement open and just keep assigning parameters and
(re)executing it.
To get the best performance out of PostgreSQL, you'll need to be running
a relatively recent PostgreSQL version (7.4 or later, I think) along
with a newer JDBC driver, and you'll want to set the prepareThreshold to
something low, like 1 or 2. See docs here:
http://jdbc.postgresql.org/documentation/80/server-prepare.html
-- Mark
On Wed, 2005-10-12 at 12:10 -0700, Hector Rosas wrote:
> Hello, I have a doubt with connections and PreparedStatemens. If I
> open a connection to Postgres and then request a prepared statement,
> this will be compiled and reused as long as I don't close the
> connection right? Or it doesn't matter if I close the connection, I'm
> using PooledConnection provided by my container (Orion), I want to
> know if there's an advantage to keep a connections open, in order to
> reutilize PreparedStatement. Also, I'm closing PreparedStatement after
> every query, PreparedStatement need to be closed after every query
> right? I mean, is not closing a PreparedStatement a way to increase
> performance?
>
> Well, thanks everyone.
>
> Jeziel.
From | Date | Subject | |
---|---|---|---|
Next Message | Aydın Toprak | 2005-10-13 06:20:07 | How to insert "date" as timestamp |
Previous Message | Oliver Jowett | 2005-10-12 19:50:36 | Re: About Connections and PreparedStatements |