Re: bytea performance tweak - Mailing list pgsql-jdbc

From Andreas Schmitz
Subject Re: bytea performance tweak
Date
Msg-id 20110622141711.GA2652@summalogicae.occamlabs.local
Whole thread Raw
In response to Re: bytea performance tweak  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: bytea performance tweak
List pgsql-jdbc
Oliver Jowett wrote:

Hi,

> On 22 June 2011 01:08, Andreas Schmitz <schmitz@occamlabs.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

Attachment

pgsql-jdbc by date:

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