• Tom Lane's avatar
    Fix some questionable edge-case behaviors in add_path() and friends. · 3b0f7760
    Tom Lane authored
    add_path_precheck was doing exact comparisons of path costs, but it really
    needs to do them fuzzily to be sure it won't reject paths that could
    survive add_path's comparisons.  (This can only matter if the initial cost
    estimate is very close to the final one, but that turns out to often be
    true.)
    
    Also, it should ignore startup cost for this purpose if and only if
    compare_path_costs_fuzzily would do so.  The previous coding always ignored
    startup cost for parameterized paths, which is wrong as of commit
    3f59be83; it could result in improper early rejection of paths that
    we care about for SEMI/ANTI joins.  It also always considered startup cost
    for unparameterized paths, which is just as wrong though the only effect is
    to waste planner cycles on paths that can't survive.  Instead, it should
    consider startup cost only when directed to by the consider_startup/
    consider_param_startup relation flags.
    
    Likewise, compare_path_costs_fuzzily should have symmetrical behavior
    for parameterized and unparameterized paths.  In this case, the best
    answer seems to be that after establishing that total costs are fuzzily
    equal, we should compare startup costs whether or not the consider_xxx
    flags are on.  That is what it's always done for unparameterized paths,
    so let's make the behavior for parameterized  paths match.
    
    These issues were noted while developing the SEMI/ANTI join costing fix
    of commit 3f59be83, but we chose not to back-patch these fixes,
    because they can cause changes in the planner's choices among
    nearly-same-cost plans.  (There is in fact one minor change in plan choice
    within the core regression tests.)  Destabilizing plan choices in back
    branches without very clear improvements is frowned on, so we'll just fix
    this in HEAD.
    3b0f7760
pathnode.c 55.4 KB