The following bug has been logged online:
Bug reference: 4414
Logged by: Rudolf Leitgeb
Email address: r.leitgeb@x-pin.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.