Thread
-
Re: Make printtup a bit faster
Andres Freund <andres@anarazel.de> — 2026-05-06T15:52:10Z
Hi, > From Andres: > > > 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. > > Puting optional context via the fcinfo looks novel to me (I have zero > experience to use fcinfo utility.). We do that in a bunch of places, e.g. for the context of window functions (c.f. PG_WINDOW_OBJECT() WindowObjectIsValid()). > Then I'm not sure how to use the optional context, Will it be a > MemoryContext or a StringInfo? If MemoryContext, then how to avoid the > memory copy in the printtup sistuation or this method has different target. I think it'd have to be something that includes the stringinfo. Here's a very rough prototype for how it could look like. This clearly needs more helpers that I introduced, but I thought this should be enough to show the idea. The first patch is a sketch of something that the second patch depends on, but that I think we should probably do independently. I'm running working on a laptop with an almost empty battery, but I'd expect it to be a bit faster than what we do today. Greetings, Andres Freund