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