Andres Freund <andres@anarazel.de> writes:
> FWIW, I've experimented fixing this overhead before, and what I did was to
> pass an optional context via the fcinfo, and output / send functions could use
> memory allocated via that optional context object, rather than doing it
> allocating in CurrentMemoryContext. For the send functions that looks
> reasonably clean, given that it already deals with a stringinfo. For out
> functions it's a bit uglier, but still somewhat acceptable.
Hmm, yeah, that could be a route to building a new optional API
without causing compatibility problems everywhere.
regards, tom lane