Re: On disable_cost

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Heikki Linnakangas <hlinnaka@iki.fi>, Peter Geoghegan <pg@bowt.ie>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-02T18:04:08Z
Lists: pgsql-hackers
On Wed, 2024-10-02 at 21:55 +1300, David Rowley wrote:
> On Tue, 1 Oct 2024 at 06:17, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> > Why did you change "Disabled" from an integer to a boolean?
> 
> I just don't think "Disabled Nodes" is all that self-documenting and
> I'm also unsure why the full integer value of disabled_nodes is
> required over just displaying the boolean value of if the node is
> disabled or not. Won't readers look at the remainder of the plan to
> determine information about which other nodes are disabled? Do we need
> to give them a running total?

I didn't want a running total, but maybe I misunderstood what a disabled
node is; see below.

> > If you see a join where two plans were disabled, that's useful information.
> 
> I'm not sure if I follow what you mean here.  The patch will show
> "Disabled: true" for both the inner and outer side of the join if both
> of those are disabled.  The difference is that my patch does not show
> the join itself is disabled like master does. I thought that's what
> you were complaining about. Can you show an example of what you mean?

I ran the following example, and now I am confused.

  CREATE TABLE tab_a (id integer);

  CREATE TABLE tab_b (id integer);

  SET enable_nestloop = off;
  SET enable_hashjoin = off;

  EXPLAIN SELECT * FROM tab_a JOIN tab_b USING (id);

                               QUERY PLAN                              
  ═════════════════════════════════════════════════════════════════════
   Merge Join  (cost=359.57..860.00 rows=32512 width=4)
     Merge Cond: (tab_a.id = tab_b.id)
     ->  Sort  (cost=179.78..186.16 rows=2550 width=4)
           Sort Key: tab_a.id
           ->  Seq Scan on tab_a  (cost=0.00..35.50 rows=2550 width=4)
     ->  Sort  (cost=179.78..186.16 rows=2550 width=4)
           Sort Key: tab_b.id
           ->  Seq Scan on tab_b  (cost=0.00..35.50 rows=2550 width=4)

I would have expected to see "Disabled nodes: 2" with the merge join,
because both the nested loop join and the hash join have been disabled.

Why is there no disabled node shown?

Yours,
Laurenz Albe





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.