Okay, I have to take back my remarks about the code being ugly -- it is pretty cool actually, very correct and not as big as I originally thought, since most of it is benchmarking code. Still, using textual queries for sending big amounts of binary data just isn't a very good idea, so I'm reluctant to add complex optimizations for that. On the bright side, I was able to reach results almost as good as your code (on SBCL at least, didn't test other implementations) by just turning off *PRINT-PRETTY* and not using FORMAT to create the octal values. A patch for that has been pushed.
cl-postgres has very simple support for sending binary data unescaped -- see the 'blob' test in its test suite for that. But the postmodern wrapper doesn't make use of this yet -- it was added by one of Attila's patches, and not part of my original 'vision' (heh). You could look into changing things so that blobs are passed through unescaped when they are given as 'parameters' to (prepared) queries. I'm not sure how to do that in a nice way -- maybe some kind of generalized system where binary sender functions can be registered for specific types.
Cheers, Marijn