Re: How to retain lesser paths at add_path()? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: How to retain lesser paths at add_path()?
Date
Msg-id 32104.1570467389@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to retain lesser paths at add_path()?  (Kohei KaiGai <kaigai@heterodb.com>)
Responses Re: How to retain lesser paths at add_path()?
List pgsql-hackers
Kohei KaiGai <kaigai@heterodb.com> writes:
> 2019年10月7日(月) 23:44 Robert Haas <robertmhaas@gmail.com>:
>> But if we want to stick with the ad-hoc method, we could also just
>> have four possible return values: dominates, dominated-by, both, or
>> neither.

> It seems to me this is a bit different from the purpose of this hook.
> I never intend to overwrite existing cost-based decision by this hook.
> The cheapest path at a particular level is the cheapest one regardless
> of the result of this hook. However, this hook enables to prevent
> immediate elimination of a particular path that we (extension) want to
> use it later and may have potentially cheaper cost (e.g; a pair of
> custom GpuAgg + GpuJoin by reduction of DMA cost).

I do not think this will work for the purpose you wish, for the reason
Tomas already pointed out: if you don't also modify the accept_new
decision, there's no guarantee that the path you want will get into
the relation's path list in the first place.

Another problem with trying to manage this only by preventing removals
is that it is likely to lead to keeping extra paths and thereby wasting
planning effort.  What if there's more than one path having the property
you want to keep?

Given the way that add_path works, you really have to think about the
problem as adding an additional figure-of-merit or comparison dimension.
Anything else is going to have some unpleasant behaviors.

> One other design in my mind is, add a callback function pointer on Path
> structure. Only if Path structure has valid pointer (not-NULL), add_path()
> calls extension's own logic to determine whether the Path can be
> eliminated now.

While I'm not necessarily against having a per-path callback, I don't
see how it helps us solve this problem, especially not in the presence
of multiple extensions trying to add different paths.  I do not wish
to see things ending up with extensions saying "don't delete my path
no matter what", because that's going to be costly in terms of later
planning effort.  But I'm not seeing how this wouldn't degenerate to
pretty much that behavior.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Transparent Data Encryption (TDE) and encrypted files
Next
From: Robert Haas
Date:
Subject: Re: [PATCH] Add some useful asserts into View Options macroses