Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3sYh-0006QS-95 for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Jan 2014 19:24:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W3sYg-0001Cr-Og for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Jan 2014 19:24:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3sYf-0001BE-NG for pgsql-jdbc@postgresql.org; Thu, 16 Jan 2014 19:24:53 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3sYb-0003Sm-9E for pgsql-jdbc@postgresql.org; Thu, 16 Jan 2014 19:24:52 +0000 Received: from [192.168.157.132] (unknown [65.19.243.151]) by outbound.vnet-inc.com (Postfix) with ESMTP id 9CA5D719E; Thu, 16 Jan 2014 12:23:51 -0700 (MST) Message-ID: <52D83125.2020908@ttc-cmc.net> Date: Thu, 16 Jan 2014 12:21:09 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Jeremy Whiting , PostgreSQL JDBC Subject: Re: Performance improvement proposal. Removal of toLowerCase calls. References: <52D7FE5E.3050503@redhat.com> In-Reply-To: <52D7FE5E.3050503@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Jeremy Whiting wrote: > Hi, > I would like to propose an optimization to improve performance in the > jdbc driver. The performance improvement has been tested on commodity > hardware using an industry standard Java benchmark. The overall > benchmark metric reports an improvement in performance. Profiling using > sampling showed calls reduced from 1100 to 0 when the benchmark workload > is running. > > The optimization will eliminate calls to the method > toLowerCase(java.util.Locale). This in the pg-jdbc > org.postgresql.jdbc2.AbstractJdbc2ResultSet.findColumnIndex(java.lang.String) > method when setting up the column index registry. > > For the optimization to be enabled I suggest relying on a new system > property. Making the existing functionality the default behaviour to > ensure existing applications do not break when the driver is upgraded. > > The change removes the call toLowerCase when putting items in the > registry [1]. Essentially what's being proposed is removing sanitizing > the key names. For best performance application code should pass SQL to > the driver with column names already folded to lower case. But upper > case names will still be matched in the second lookup [2] in the method. **************** > For this optimization to work this feature introduces a requirement on > applications. To use all lower or upper case column names. **************** This is going to break existing applications, if the requirement is to have either upper or lowercase. I test explicitly with the MyJSQLView application the use of mixed case column, key index names because there are applications that used mixed case. The proper way to handle is quote to handle the mixed case so it is store as such. Perhaps the optimization could check for quoting then do no addition process and store directly intact. Other wise the optimization could initiate as proposed. danap. > > Are there other factors that might affect this optimization that need > to be taken into consideration ? > > Regards, > Jeremy Whiting > > Senior Software Engineer > Red Hat > > [1] > https://github.com/pgjdbc/pgjdbc/blob/REL9_3_STABLE/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java?#L2742 > [2] > https://github.com/pgjdbc/pgjdbc/blob/REL9_3_STABLE/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java?#L2752 > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc