From: Kris Jurka <books@ejurka.com>
To: Teun Hoogendoorn <th@atsc.nl>
Cc: pgsql-bugs@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: Re: BUG #6293: JDBC driver performance
Date: Wed, 16 Nov 2011 16:29:36 -0500 (EST)
Message-ID: <alpine.BSO.2.00.1111161621580.14447@leary.csoft.net> (raw)
In-Reply-To: <201111150859.pAF8xKZW012012@wwwmaster.postgresql.org>
References: <201111150859.pAF8xKZW012012@wwwmaster.postgresql.org>
On Tue, 15 Nov 2011, Teun Hoogendoorn wrote:
>
> The following bug has been logged online:
>
> Bug reference: 6293
> PostgreSQL version: 9.1
> Description: JDBC driver performance
> Details:
>
> Using the postgresql-9.1-901.jdbc3.jar driver instead of
> postgresql-9.0-801.jdbc3.jar drops performance dramatically.
>
> I think it has something to do with using ResultSetMetaData in Java. The
> postgres log shows me hundreds of identical query's when retrieving the
> ResultSetMetaData for a single query. I'm not using an ORM framework, just
> simple JDBC calls.
The 9.1 JDBC driver was changed to try and fetch all metadata for the
entire resultset in one query instead of potentially issuing multiple
queries for each column. So this change was supposed to improve things.
Looking at the code, the caching pattern has changed slightly, so now it's
important to hold onto the same ResultSetMetaData instance. That is you
need to do:
ResultSet rs = ...
ResultSetMetaData rsmd = rs.getMetaData();
for (int i=1; i<rsmd.getColumnCount(); i++) {
// good
System.out.println(rsmd.getAutoIncrement());
// bad
System.out.println(rs.getMetaData().getAutoIncrement());
}
The driver should probably be changed to hand back the same
ResultSetMetaData instance each time instead of a new one for each
MetaData call.
Does this explain your problem? If not, can you provide more details on
how you access and use ResultSetMetaData?
Kris Jurka
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: books@ejurka.com, th@atsc.nl, pgsql-bugs@postgresql.org
Subject: Re: BUG #6293: JDBC driver performance
In-Reply-To: <alpine.BSO.2.00.1111161621580.14447@leary.csoft.net>
References: <201111150859.pAF8xKZW012012@wwwmaster.postgresql.org> <alpine.BSO.2.00.1111161621580.14447@leary.csoft.net>
* 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