BUG #4414: PQescapeByteaInternal very slow/inefficient

From: "Rudolf Leitgeb" <r(dot)leitgeb(at)x-pin(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4414: PQescapeByteaInternal very slow/inefficient
Date: 2008-09-10 11:12:58
Message-ID: 200809101112.m8ABCwxg080817@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4414
Logged by: Rudolf Leitgeb
Email address: r(dot)leitgeb(at)x-pin(dot)com
PostgreSQL version: 8.3.3
Operating system: Mac OSX, linux
Description: PQescapeByteaInternal very slow/inefficient
Details:

PQescapeByteaInternal uses sprintf to convert a byte to its octal
representation, which slows down escaping of large BLOBs significantly. A
simple replacement table could achieve the same effect with much better
performance with only minimal extra memory requirements.

The routine is located in fe-exec.c
The call
(void) sprintf((char *) rp, "\\%03o", *vp);
could be replaced by
memcpy((char *)rp, lookuptable[*vp]);
rp += otherlookuptable[*vp];
with a properly configured lookuptable and otherlookuptable.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2008-09-10 17:02:04 Re: BUG #4414: PQescapeByteaInternal very slow/inefficient
Previous Message Peter Eisentraut 2008-09-10 10:01:50 Re: issue with postgres/xml