Re: Performance of setTimestamp and getTimestamp

From: Kris Jurka <books(at)ejurka(dot)com>
To: Bryce Ewing <brycenz(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Performance of setTimestamp and getTimestamp
Date: 2004-12-20 08:40:29
Message-ID: Pine.BSO.4.56.0412200323500.25555@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, 20 Dec 2004, Bryce Ewing wrote:

> Not sure if this has been mentioned before but I have found that in my
> development an extraordinary amount of time is being spent in these
> two methods, just to give you an idea in two cases recently during
> bulk operations I have found that 21% and 72% of the time to do the
> bulk loads/bulk processing has been spent in setTimestamp and
> getTimestamp respectively.

That's not good.

> I first found that setTimestamp was going to be a performance issue
> for me so I decided to see if I could find a faster way of doing it,
> from the test code below I found that I had a 3 times improvement in
> just using SimpleDateFormat to format the timestamp (the setTimestamp
> method was copied from the jdbc drivers with a couple of small
> changes).
>
> Note that at present I am using 7.4 and so I am not so sure how this
> fits in with the push for 8.
>

I rewrote both the set/getTimestamp code for 8.0 last week. Using your
test I've made some further modifications and I now see numbers like so
from my attached modification of your test:

setTimestamp74 took: 4930
setTimestamp80 took: 1999
format took: 1503

Note that your method does not correctly handle BC dates, dates past 9999
or fractional seconds beyond milliseconds which the 8.0 code does. If you
have any further ideas and improvements we would definitely like to hear
about them.

Kris Jurka

Attachment Content-Type Size
tsperf.java text/plain 8.1 KB

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2004-12-20 17:15:03 Re: Bug in JDBC-Driver?
Previous Message Bryce Ewing 2004-12-20 04:43:50 Performance of setTimestamp and getTimestamp