Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 99109B5DC0F for ; Wed, 22 Jun 2011 11:17:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 44494-06 for ; Wed, 22 Jun 2011 14:17:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.lat-lon.de (mail.lat-lon.de [178.63.90.186]) by mail.postgresql.org (Postfix) with ESMTP id 7A040B5DBF0 for ; Wed, 22 Jun 2011 11:17:23 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.lat-lon.de (Postfix) with ESMTP id C888F198003; Wed, 22 Jun 2011 16:17:22 +0200 (CEST) X-Virus-Scanned: by amavisd-new at lat-lon.de Received: from mail.lat-lon.de ([127.0.0.1]) by localhost (mail.lat-lon.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b8T2ZGw7zJW0; Wed, 22 Jun 2011 16:17:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.lat-lon.de (Postfix) with ESMTP id 3F7EE198005; Wed, 22 Jun 2011 16:17:14 +0200 (CEST) Received: from localhost (unknown [217.203.68.35]) (Authenticated sender: schmitz@lat-lon.de) by mail.lat-lon.de (Postfix) with ESMTP id ACEDC198003; Wed, 22 Jun 2011 16:17:13 +0200 (CEST) Date: Wed, 22 Jun 2011 16:17:12 +0200 From: Andreas Schmitz To: Oliver Jowett Cc: pgsql-jdbc@postgresql.org Subject: Re: bytea performance tweak Message-ID: <20110622141711.GA2652@summalogicae.occamlabs.local> References: <20110621130713.GB3919@summalogicae.occamlabs.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="r5Pyd7+fXNt84Ff3" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/51 X-Sequence-Number: 21975 --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Oliver Jowett wrote: Hi, > On 22 June 2011 01:08, Andreas Schmitz 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? >=20 > 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 --r5Pyd7+fXNt84Ff3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk4B+WcACgkQ737OVr+Ru7qREgCfU6TiJCs39BRN4ZyTIWAUnSEm QgEAoIluosG8+fb1wulI4qw+tRmp7KB1 =uWev -----END PGP SIGNATURE----- --r5Pyd7+fXNt84Ff3--