agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
From: Andy Fan <zhihuifan1213@163.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Make printtup a bit faster
Date: Thu, 07 May 2026 20:40:40 +0800
Message-ID: <87cxz78kaf.fsf@163.com> (raw)
In-Reply-To: <7nfy6enxgwzptesyd2oexlwtqaxtlhbec4yqs44mqgjbyanpss@icwtswsr3wam>
References: <87wmjzfz0h.fsf@163.com>
	<CAApHDvrBNA-QRsbn-SJyRAsywjHCNenfcbi14c3O3c7=OimQ8Q@mail.gmail.com>
	<87bk1aj2go.fsf@163.com>
	<CAApHDvqHthJb6baDhgTE5T4RLW6nEX=r239EYmpjfg=Wq5CqQA@mail.gmail.com>
	<877bpk7dyg.fsf@163.com>
	<117986.1777869518@sss.pgh.pa.us>
	<877bpghevm.fsf@163.com>
	<7nfy6enxgwzptesyd2oexlwtqaxtlhbec4yqs44mqgjbyanpss@icwtswsr3wam>

Andres Freund <andres@anarazel.de> writes:

> 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.

Yes, so optional context is really elegant. Thanks for sharing!

> A closely related precedent is the introduction of "soft error
> reporting" for input functions.  See d9f7f5d32 and follow-ons.

Thanks for this example as well!

-- 
Best Regards
Andy Fan






view thread (24+ messages)  latest in thread

Message-ID: <87cxz78kaf.fsf@163.com>
Permalink:  ../87cxz78kaf.fsf@163.com/
Also on:    postgresql.org/message-id/87cxz78kaf.fsf@163.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: zhihuifan1213@163.com, andres@anarazel.de, tgl@sss.pgh.pa.us, dgrowleyml@gmail.com
  Subject: Re: Make printtup a bit faster
  In-Reply-To: <87cxz78kaf.fsf@163.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox