Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A7D7B15B5F5 for ; Wed, 16 Nov 2011 17:29:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 76650-08; Wed, 16 Nov 2011 21:29:52 +0000 (UTC) Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C0A0715B5F4; Wed, 16 Nov 2011 17:29:51 -0400 (AST) Received: from mail63.csoft.net ([205.205.214.4]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RQn3E-0000fl-Tm; Wed, 16 Nov 2011 21:29:51 +0000 Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 45F12284D1; Wed, 16 Nov 2011 16:29:36 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=3DKK1tuSs2kg6QGJ3y6fuV9R1/g=; b=kLEEXo S3Dx3DWBgZ7xm6ileEsKeknHldnD8glVbosDrduxRTUEzgOHps56tQush396DWPm PGbrP9QaqEjBo9sR2X7CcbMeNpxGrTWApY1yN2Rn3EgdJ7VyHySG0lh21FC4yhJl g7lkv2HARQ5LzMSFmCrm38Buhiw1XOqQg009g= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 2E02F284D3; Wed, 16 Nov 2011 16:29:36 -0500 (EST) Received: by leary.csoft.net (Postfix, from userid 1112) id 18D2DA188; Wed, 16 Nov 2011 16:29:36 -0500 (EST) Date: Wed, 16 Nov 2011 16:29:36 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Teun Hoogendoorn cc: pgsql-bugs@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: BUG #6293: JDBC driver performance In-Reply-To: <201111150859.pAF8xKZW012012@wwwmaster.postgresql.org> Message-ID: References: <201111150859.pAF8xKZW012012@wwwmaster.postgresql.org> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201111/118 X-Sequence-Number: 31713 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