| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Andy Fan <zhihuifan1213(at)163(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Make printtup a bit faster |
| Date: | 2026-05-06 15:52:10 |
| Message-ID: | 7nfy6enxgwzptesyd2oexlwtqaxtlhbec4yqs44mqgjbyanpss@icwtswsr3wam |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| va1-0001-WIP-Use-permanent-FunctionCallInfo-in-printtup.patch | text/x-diff | 2.4 KB |
| va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch | text/x-diff | 7.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-05-06 16:02:08 | Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL |
| Previous Message | Andrew Dunstan | 2026-05-06 15:50:04 | Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL |