Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 3C362632ED3 for ; Sun, 19 Apr 2009 05:56:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 48954-05 for ; Sun, 19 Apr 2009 05:56:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og109.obsmtp.com (exprod7og109.obsmtp.com [64.18.2.171]) by mail.postgresql.org (Postfix) with SMTP id C7B85634705 for ; Sun, 19 Apr 2009 05:18:11 -0300 (ADT) Received: from source ([209.85.218.178]) by exprod7ob109.postini.com ([64.18.6.12]) with SMTP ID DSNKSereQnBqxJhbzgYEcJX3GEHDz80tv5kK@postini.com; Sun, 19 Apr 2009 01:18:11 PDT Received: by bwz26 with SMTP id 26so1545630bwz.2 for ; Sun, 19 Apr 2009 01:18:09 -0700 (PDT) Received: by 10.103.11.7 with SMTP id o7mr2372891mui.103.1240129089607; Sun, 19 Apr 2009 01:18:09 -0700 (PDT) Received: from ?85.77.235.164? (KMMMDCCCLXIII.gprs.sl-laajakaista.fi [85.77.235.164]) by mx.google.com with ESMTPS id t10sm10552114muh.22.2009.04.19.01.17.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 19 Apr 2009 01:18:08 -0700 (PDT) Message-ID: <49EADDCE.90500@enterprisedb.com> Date: Sun, 19 Apr 2009 11:16:14 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Kris Jurka CC: pgsql-jdbc@postgresql.org Subject: Re: Fast BigDecimal References: <49E72C90.9010903@enterprisedb.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------030007060609030202080503" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200904/67 X-Sequence-Number: 19514 This is a multi-part message in MIME format. --------------030007060609030202080503 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Kris Jurka wrote: > > > On Sat, 18 Apr 2009, Kris Jurka wrote: > >> On Thu, 16 Apr 2009, Heikki Linnakangas wrote: >> >>> Here's another patch I put together while trying to improve >>> performance for the customer that bumped into the repeated Describe >>> thing yesterday. It speeds up ResultSet.getBigDecimal() with the same >>> fastpath implementation we have for getInt and getLong. >> >> To maintain the same behavior as the current code, you need to handle >> the period more carefully. You must ensure that there is only one and >> that there's at least one other number. Consider the case of SELECT >> '.' OR SELECT '1.......'. >> > > For some reason I thought this would be tricky. We just need to track > the total number for periods seen and error out if > 1 or equal to the > total number of characters. I've done that and committed it. Thanks. One more thing: this accepts "-.", which the normal version doesn't. Patch attached. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------030007060609030202080503 Content-Type: text/x-diff; name="a.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="a.patch" Index: org/postgresql/jdbc2/AbstractJdbc2ResultSet.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v retrieving revision 1.106 diff -c -r1.106 AbstractJdbc2ResultSet.java *** org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 19 Apr 2009 05:18:31 -0000 1.106 --- org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 19 Apr 2009 08:15:03 -0000 *************** *** 2191,2197 **** val += b - '0'; } ! if (periodsSeen > 1 || periodsSeen == bytes.length) throw FAST_NUMBER_FAILED; if (neg) { --- 2191,2198 ---- val += b - '0'; } ! if (periodsSeen > 1 || ! periodsSeen == (neg ? bytes.length - 1 : bytes.length)) throw FAST_NUMBER_FAILED; if (neg) { --------------030007060609030202080503--