Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3p7X-0005PH-5m for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Jan 2014 15:44:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W3p7W-00025X-L9 for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Jan 2014 15:44:38 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3p7V-00024N-JO for pgsql-jdbc@postgresql.org; Thu, 16 Jan 2014 15:44:37 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3p7S-0001Zg-7f for pgsql-jdbc@postgresql.org; Thu, 16 Jan 2014 15:44:37 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0GFiXBG026253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 Jan 2014 10:44:33 -0500 Received: from [10.33.1.208] (dhcp-1-208.fab.redhat.com [10.33.1.208]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0GFiUXf016286 for ; Thu, 16 Jan 2014 10:44:32 -0500 Message-ID: <52D7FE5E.3050503@redhat.com> Date: Thu, 16 Jan 2014 15:44:30 +0000 From: Jeremy Whiting User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Performance improvement proposal. Removal of toLowerCase calls. X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Pg-Spam-Score: -5.8 (-----) 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 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. 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