8.2 driver getBoolean(...) performance question - Mailing list pgsql-jdbc

From Fear, Jake
Subject 8.2 driver getBoolean(...) performance question
Date
Msg-id 7EA6A25EC6360A488E0EBB5F3F21A0DC15D1CBC6@mail-sd4.ad.soe.sony.com
Whole thread Raw
Responses Re: 8.2 driver getBoolean(...) performance question
List pgsql-jdbc

I’ve been profiling an application using both the 8.1 and 8.2 drivers (congratulations on the improvements!) and I have a question regarding the order in which the values in the method AbstractJdbc2ResultSet are interpreted:

 

Here is the  block of code in question:

 

            if (s.equalsIgnoreCase("t") || s.equalsIgnoreCase("true") || s.equals("1"))

                return true;

 

            if (s.equalsIgnoreCase("f") || s.equalsIgnoreCase("false") || s.equals("0"))

                return false;

 

It checks t then true then 1, but the code in the method AbstractJdbc2Statement.setBoolean:

    public void setBoolean(int parameterIndex, boolean x) throws SQLException

    {

        checkClosed();

        bindString(parameterIndex, x ? "1" : "0", Oid.BOOL);

    }

 

Seems to indicate the 0 or 1, if the drivers are being used as expected, will be the preferred values, and would make sense on the left hand site of the short-circuiting || operation in the result set class.

 

The getBoolean method isn’t nearly as high in the profiler as it was on the 8.1 drivers, but it is still showing up consuming more CPU than I would expect.

 

So my question is this:  Is there anything I’m missing that actually makes the t/f values the preferred test?  Am I missing something on the statement side that makes this more efficient?  In my particular case (using Hibernate and explicitly using boolean data types) putting the 0/1 test first is more efficient.

 

Thanks,

 

Jake Fear

Software Engineering Supervisor

Sony Online Entertainment

858-790-3526

 

pgsql-jdbc by date:

Previous
From: Paul Tomblin
Date:
Subject: Re: What changed?
Next
From: Kris Jurka
Date:
Subject: Re: 8.2 driver getBoolean(...) performance question