On Mon, Jul 8, 2013 at 9:03 PM, Leon Smith <leon.p.smith@gmail.com> wrote:
I just fixed a fairly serious performance problem with postgresql-libpq's binding to PQescapeStringConn;   in was exhibiting a non-linear slowdown when more strings are escaped and retained.

 I'd like to point out a somewhat related bottleneck in postgresql-simple (but not postgresql-libpq).  Every PQescapeStringConn or PQescapeByteaConn call involves a withMVar, which is about 100ns on the threaded RTS on my system.  Taking the Connection lock once for the whole buildQuery call might be much faster, especially for multi-row inserts and updates.