X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E23BE9FB3A1 for ; Thu, 24 Aug 2006 01:09:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 27353-06 for ; Thu, 24 Aug 2006 01:09:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by postgresql.org (Postfix) with ESMTP id 2D5479FB37A for ; Thu, 24 Aug 2006 01:09:25 -0300 (ADT) Received: from 203-118-178-246.bliink.ihug.co.nz ([203.118.178.246] helo=[10.1.1.6]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1GG6Ww-00018p-W5; Thu, 24 Aug 2006 16:09:23 +1200 Message-ID: <44ED2671.3070709@opencloud.com> Date: Thu, 24 Aug 2006 16:09:21 +1200 From: Oliver Jowett User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: "j.random.programmer" CC: pgsql-jdbc@postgresql.org Subject: Re: Some simple JDBC profiling results References: <20060823195511.93081.qmail@web32004.mail.mud.yahoo.com> In-Reply-To: <20060823195511.93081.qmail@web32004.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.143 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200608/115 X-Sequence-Number: 15642 j.random.programmer wrote: > I ran a profiler recently on some java code (part of > which was using > the postgres JDBC driver) and saw the following > hotspots within the driver: > > org.postgresql.core.Encoding.decode (line: 193) > org.postgresql.core.Encoding.decode (line: 347) > > I think there might be excessive new String creation > at those points > cause those 2 lines really light up the profiler. As pointed out by others there is not "excessive string creation" as those methods are explicitly designed to return a new String .. The issue is probably that the callers use it too much. If you attribute the cost of Encoding.decode() to its callers, what do the hotspots look like then? It looks that Encoding.getDatabaseEncoding() actually fails to return the specialized UTF8Encoding when it could, so we're still using the generic version (which works, but is slower) .. I suspect I didn't test that properly when I last modified that code. But if String creation is really the problem, then that's not going to help you anyway. -O