The v2 patch is attached. This adds two dedicated lists on the RelOptInfo to preserve lesser paths if extension required to retain the path-node to be removed in usual manner. These lesser paths are kept in the separated list, so it never expand the length of pathlist and partial_pathlist. That was the arguable point in the discussion at the last October.
The new hook is called just before the path-node removal operation, and gives extension a chance for extra decision. If extension considers the path-node to be removed can be used in the upper path construction stage, they can return 'true' as a signal to preserve this lesser path-node. In case when same kind of path-node already exists in the preserved_pathlist and the supplied lesser path-node is cheaper than the old one, extension can remove the worse one arbitrarily to keep the length of preserved_pathlist. (E.g, PG-Strom may need one GpuJoin path-node either pathlist or preserved- pathlist for further opportunity of combined usage with GpuPreAgg path-node. It just needs "the best GpuJoin path-node" somewhere, not two or more.) Because PostgreSQL core has no information which preserved path-node can be removed, extensions that uses path_removal_decision_hook() has responsibility to keep the length of preserved_(partial_)pathlist reasonable. BTW, add_path() now removes the lesser path-node by pfree(), not only detach from the path-list. (IndexPath is an exception) Does it really make sense? It only releases the path-node itself, so may not release entire objects. So, efficiency of memory usage is limited. And ForeignScan / CustomScan may references the path-node to be removed. It seems to me here is no guarantee lesser path-nodes except for IndexPath nodes are safe to release. Best regards, 2020年1月11日(土) 21:27 Tomas Vondra <tomas.von...@2ndquadrant.com>: > > On Sat, Jan 11, 2020 at 05:07:11PM +0900, Kohei KaiGai wrote: > >Hi, > > > >The proposition I posted at 10th-Oct proposed to have a separate list to > >retain > >lesser paths not to expand the path_list length, but here are no comments by > >others at that time. > >Indeed, the latest patch has not been updated yet. > >Please wait for a few days. I'll refresh the patch again. > > > > OK, thanks for the update. I've marked the patch as "waiting on author". > > > regards > > -- > Tomas Vondra http://www.2ndQuadrant.com > PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- HeteroDB, Inc / The PG-Strom Project KaiGai Kohei <kai...@heterodb.com>
pgsql13-path_removal_decision_hook.v2.patch
Description: Binary data