Re: BUG #6293: JDBC driver performance

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: BUG #6293: JDBC driver performance
Дата
Msg-id alpine.BSO.2.00.1111161621580.14447@leary.csoft.net
обсуждение исходный текст
Ответ на BUG #6293: JDBC driver performance  ("Teun Hoogendoorn" <th@atsc.nl>)
Ответы Re: [JDBC] BUG #6293: JDBC driver performance  (Steven Schlansker <stevenschlansker@gmail.com>)
Список pgsql-bugs

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


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: Cannot dump 8.4.8 database using later versions
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: BUG #6292: java.sql.PreparedStatement.setNull() throws PSQLException