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: Heikki Linnakangas <hlinnaka@iki.fi>,
"Jonathan S. Katz" <jkatz@postgresql.org>,
David Rowley <dgrowleyml@gmail.com>, Peter Geoghegan <pg@bowt.ie>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
andrew@ankane.org
Date: 2024-08-23T18:48:35Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes: > On Fri, Aug 23, 2024 at 2:18 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote: >> It would seem useful for an index AM to be able to say "nope, I can't do >> this". I don't remember how exactly this stuff works, but I'm surprised >> it doesn't already exist. > Yeah, I think so, too. While this particular problem is due to a > problem with an out-of-core AM that may be doing some slightly > questionable things, there's not really any reason why we couldn't > have similar problems in core for some other reason. For example, we > could change amcostestimate's signature so that an extension can > return true or false, with false meaning that the path can't be > supported. We could then change cost_index so that it can also return > true or false, and then change create_index_path so it has the option > to return NULL. Callers of create_index_path could then be adjusted > not to call add_path when NULL is returned. If we're going to do this, I'd prefer a solution that doesn't force API changes onto the vast majority of index AMs that don't have a problem here. One way could be to formalize the hack we were just discussing: "To refuse a proposed path, amcostestimate can set the path's disabled_nodes value to anything larger than 1". I suspect that that would actually be sufficient, since the path would then lose to the seqscan path in add_path even if that were disabled; but we could put in a hack to prevent it from getting add_path'd at all. Another way could be to bless what hnsw is already doing: "To refuse a proposed path, amcostestimate can return an indexTotalCost of DBL_MAX" (or maybe insisting on +Inf would be better). That would still require changes comparable to what you specify above, but only in the core-code call path not in every AM. regards, tom lane
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