Re: bytea performance tweak - Mailing list pgsql-jdbc

From Craig Ringer
Subject Re: bytea performance tweak
Date
Msg-id 4E016112.3080709@postnewspapers.com.au
Whole thread Raw
In response to Re: bytea performance tweak  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: bytea performance tweak  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
On 22/06/11 07:59, Oliver Jowett wrote:
> On 22 June 2011 01:08, Andreas Schmitz <schmitz@occamlabs.de> wrote:
>> Hi,
>>
>> I've noticed that fetching a bytea field produces a lot of overhead when
>> converting into a byte[] or InputStream. Looking at the code, I've
>> produced a small patch (a lookup table for the hex codes) which makes
>> the conversion faster. What do you think?
>
> Surprising.

It's not at _all_ surprising that an array index lookup is much faster
than two function calls and a bunch of branches. It'll probably JIT
better and be easier on cache, too.

If Oliver is lobbing around mostly bytea data and/or using big bytea
fields I'm not surprised he's seeing this as at least somewhat of a
hotspot. I've seen comments on bytea performance with JDBC here before,
though nobody seems to have dug into it enough to track things down before.

Thanks Oliver!

--
Craig Ringer

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: bytea performance tweak
Next
From: Oliver Jowett
Date:
Subject: Re: bytea performance tweak