Re: On disable_cost
Alena Rybakina <a.rybakina@postgrespro.ru>
From: Alena Rybakina <a.rybakina@postgrespro.ru>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>,
Laurenz Albe <laurenz.albe@cybertec.at>, 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-05T17:29:50Z
Lists: pgsql-hackers
Hi! On 04.10.2024 00:52, David Rowley wrote: > One thing the patch did cause me to find is the missing propagation of > disabled_nodes in make_sort(). It was very obviously wrong with the > patched EXPLAIN output and wasn't so obvious with the current output, > so perhaps you could look at this patch as a better way of ensuring > the disable_node propagation is correct. That's much harder logic to > get right than what I've added to explain.c as it's spread out in many > places. > > Take this case, for example: > > create table lp (a int) partition by list(a); > create table lp1 partition of lp for values in(1); > create table lp2 partition of lp for values in(2); > create index on lp1(a); > insert into lp select 1 from generate_Series(1,1000000); > analyze lp; > set enable_sort=0; > explain (costs off) select * from lp order by a; > > master gives: > > Append > Disabled Nodes: 1 > -> Index Only Scan using lp1_a_idx on lp1 lp_1 > -> Sort > Sort Key: lp_2.a > -> Seq Scan on lp2 lp_2 > > which isn't correct. Append appears disabled, but it's not. Sort is. > Before I fixed that in the patch, I was incorrectly getting the > "Disabled: true" under the Append. I feel we're more likely to get bug > reports alerting us to incorrect logic when the disabled property only > appears on disabled nodes as there are far fewer of them to look at > and therefore it's more obvious when they're misplaced. > > The patched version correctly gives us: > > Append > -> Index Only Scan using lp1_a_idx on lp1 lp_1 > -> Sort > Disabled: true > Sort Key: lp_2.a > -> Seq Scan on lp2 lp_2 To be honest, I don’t understand at all why we don’t count disabled nodes for append here? As I understand it, this is due to the fact that the partitioned table can also be scanned by an index. Besides mergeappend, in general it’s difficult for me to generalize for which nodes this rule applies, can you explain here? -- Regards, Alena Rybakina Postgres Professional
Commits
-
Doc: add detail about EXPLAIN's "Disabled" property
- 84b8fccbe5c2 18.0 landed
-
Adjust EXPLAIN's output for disabled nodes
- 161320b4b960 18.0 landed
-
Fix order of parameters in a cost_sort call
- 87b6c3c0b703 18.0 landed
-
Show number of disabled nodes in EXPLAIN ANALYZE output.
- c01743aa4866 18.0 landed
-
Treat number of disabled nodes in a path as a separate cost metric.
- e22253467942 18.0 landed
-
Remove grotty use of disable_cost for TID scan plans.
- e4326fbc60c4 18.0 landed