Re: Reducing output size of nodeToString

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Michel Pelletier <pelletier(dot)michel(at)gmail(dot)com>
Subject: Re: Reducing output size of nodeToString
Date: 2026-11-25 18:13:15
Message-ID: 1302314.1795630395@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Fri, Mar 22, 2024 at 5:18 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>> I think to proceed we need more buy-in on the "what do I want from my
>> node dumps" side, and more performance numbers on the other side.
>> Saving a few hundred kilobytes on view storage is fine but isn't by
>> itself that useful, I think, if it potentially negatively affects other
>> uses.

> I'd like to revive this thread, because I was looking at this topic
> today and then realized Matthias had already done a lot of work on it.

I agree that this is an area that could use some work. But I think
that if we're going to touch it, we should go considerably further
than making marginal tweaks to the textual representation of node
trees. I'd like to see us using a binary-oriented representation
in stored catalogs, which I think could be both a lot more compact
and a lot faster to read than what we have now. This would entail
changing pg_node_tree into a real data type instead of a thin
wrapper over text, but that doesn't seem like a problem. To the
extent that we still want the existing text representation anywhere,
that could be produced by an output function.

Having done that, we could also think about abbreviating node dumps
somehow, because I agree with Robert's point that the current dumps
are annoyingly verbose for most purposes. But that should be
independent of what we use for the storage format.

The one advantage that the textual representation has is that it's
fairly robust: it doesn't break if you change nodeTag assignments,
and if you change the number of fields in a node struct, you'll get
errors when trying to read old catalog contents. But the apparent
robustness of labeling all the fields is illusory, because readfuncs
doesn't actually verify those labels :-(. We could get the same
amount of protection with a one-byte number-of-fields entry.
Storing binary nodeTag numbers would indeed lose some robustness
compared to text struct-type names, but maybe that's an okay tradeoff.

Years ago I would have been worried about the amount of work needed to
make such a conversion, but now that the node I/O code is practically
all machine-generated, I think that it wouldn't be too bad.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Peter Geoghegan 2026-11-25 18:08:30 Re: GiST multirange index scans can fail to return rows