Re: BUG #2236: extremely slow to get unescaped bytea data - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: BUG #2236: extremely slow to get unescaped bytea data
Date
Msg-id 20060208065839.GA18717@winnie.fuhr.org
Whole thread Raw
In response to Re: BUG #2236: extremely slow to get unescaped bytea data  (Kalador Tech Support <support@kalador.com>)
Responses Re: BUG #2236: extremely slow to get unescaped bytea data
List pgsql-bugs
On Sat, Feb 04, 2006 at 04:06:11PM -0800, Kalador Tech Support wrote:
> I've since isolated the problem to the unescape_bytea function not the
> SELECT.
>
> I inserted the same image to a bytea column using base64 encoding, and
> extracted it from the table (using base64 decoding) and this worked very
> fast (<1 second).  So, it is the unescape_bytea function that is to blame.

pg_unescape_bytea is fast here; I just unescaped an 850K jpeg image
in about 0.18 seconds on a slow (500MHz) machine.

How did you determine that pg_unescape_bytea was the problem?  What
does something like the following show?

$tstart = microtime(true);
$data = pg_unescape_bytea(pg_fetch_result($res, 'data'));
$dt = microtime(true) - $tstart;
header("Content-Type: text/plain");
printf("unescape time = %.3fms, %d bytes\n", $dt * 1000.0, strlen($data));

--
Michael Fuhr

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: vacuum segmentation fault
Next
From: "Andy Klosterman"
Date:
Subject: BUG #2246: Bad malloc interactions: ecpg, openssl