Re: On disable_cost

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Jian Guo <gjian@vmware.com>, Euler Taveira <euler@timbira.com.br>, Zhenghua Lyu <zlyu@vmware.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-04-01T21:00:11Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> One of the things I realized relatively early is that the patch does
> nothing to propagate disable_cost upward through the plan tree.
> ...
> After straining my brain over various plan changes for a long time,
> and hacking on the code somewhat, I realized that just propagating the
> Boolean upward is insufficient to set things right. That's basically
> because I was being dumb when I said this:
>> I don't think we should care how MANY disabled nodes appear in a
>> plan, particularly.

Very interesting, thanks for the summary.  So the fact that
disable_cost is additive across plan nodes is actually a pretty
important property of the current setup.  I think this is closely
related to one argument you made against my upthread idea of using
IEEE Infinity for disable_cost: that'd mask whether more than one
of the sub-plans had been disabled.

> ... And while there's probably more than one way
> to make it work, the easiest thing seems to be to just have a
> disabled-counter in every node that gets initialized to the total
> disabled-counter values of all of its children, and then you add 1 if
> that node is itself doing something that is disabled, i.e. the exact
> opposite of what I said in the quote above.

Yeah, that seems like the next thing to try if anyone plans to pursue
this further.  That'd essentially do what we're doing now except that
disable_cost is its own "order of infinity", entirely separate from
normal costs.

			regards, tom lane



Commits

  1. Doc: add detail about EXPLAIN's "Disabled" property

  2. Adjust EXPLAIN's output for disabled nodes

  3. Fix order of parameters in a cost_sort call

  4. Show number of disabled nodes in EXPLAIN ANALYZE output.

  5. Treat number of disabled nodes in a path as a separate cost metric.

  6. Remove grotty use of disable_cost for TID scan plans.