From: Craig Ringer <craig@postnewspapers.com.au>
To: Oliver Jowett <oliver@opencloud.com>
Cc: Andreas Schmitz <schmitz@occamlabs.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: bytea performance tweak
Date: Wed, 22 Jun 2011 11:27:14 +0800
Message-ID: <4E016112.3080709@postnewspapers.com.au> (raw)
In-Reply-To: <BANLkTimryw=Sm5q4v53PQNkdi+RjAfgJBA@mail.gmail.com>
References: <20110621130713.GB3919@summalogicae.occamlabs.local>
<BANLkTimryw=Sm5q4v53PQNkdi+RjAfgJBA@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: craig@postnewspapers.com.au, oliver@opencloud.com, schmitz@occamlabs.de
Subject: Re: bytea performance tweak
In-Reply-To: <4E016112.3080709@postnewspapers.com.au>
References: <20110621130713.GB3919@summalogicae.occamlabs.local> <BANLkTimryw=Sm5q4v53PQNkdi+RjAfgJBA@mail.gmail.com> <4E016112.3080709@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox