Re: Make printtup a bit faster - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Make printtup a bit faster
Date
Msg-id 7nfy6enxgwzptesyd2oexlwtqaxtlhbec4yqs44mqgjbyanpss@icwtswsr3wam
Whole thread
In response to Re: Make printtup a bit faster  (Andy Fan <zhihuifan1213@163.com>)
Responses Re: Make printtup a bit faster
List pgsql-hackers
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

Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL
Next
From: Tom Lane
Date:
Subject: Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL