Re: bytea performance tweak

From: Andreas Schmitz <schmitz(at)occamlabs(dot)de>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: bytea performance tweak
Date: 2011-06-22 14:17:12
Message-ID: 20110622141711.GA2652@summalogicae.occamlabs.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Oliver Jowett wrote:

Hi,

> On 22 June 2011 01:08, Andreas Schmitz <schmitz(at)occamlabs(dot)de> wrote:
> > 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. How did you benchmark it?

I did some local tests using a main function, with a static array. I've
seen times like ~1900ms for decoding using the unpatched version, and
~1600ms for the patched version. I've also benchmarked my application
(which makes heavy use of bytea), and have seen some speedup there as
well (around 2-300ms faster when decoding ~23000 bytea rows with ~30MB
of data in total).

I was wondering why the protocol uses such an encoding anyway. Wouldn't
it be a lot faster just sending the bytes as they are?

Best regards, Andreas

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andreas Schmitz 2011-06-22 14:22:06 Re: bytea performance tweak
Previous Message Oliver Jowett 2011-06-22 07:57:53 Re: bytea performance tweak