From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Teun Hoogendoorn <th(at)atsc(dot)nl> |
Cc: | pgsql-bugs(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: BUG #6293: JDBC driver performance |
Date: | 2011-11-16 21:29:36 |
Message-ID: | alpine.BSO.2.00.1111161621580.14447@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-jdbc |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2011-11-16 21:38:46 | Re: BUG #6292: java.sql.PreparedStatement.setNull() throws PSQLException |
Previous Message | Josh Berkus | 2011-11-16 19:52:16 | Re: Cannot dump 8.4.8 database using later versions |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Harbulot | 2011-11-16 21:31:11 | Re: SSL patch |
Previous Message | Kris Jurka | 2011-11-16 21:20:10 | Re: avoid prepared statements on complex queries? |