• Tom Lane's avatar
    Improve relation width estimation for subqueries. · 0f61d4dd
    Tom Lane authored
    As per the ancient comment for set_rel_width, it really wasn't much good
    for relations that aren't plain tables: it would never find any stats and
    would always fall back on datatype-based estimates, which are often pretty
    silly.  Fix that by copying up width estimates from the subquery planning
    process.
    
    At some point we might want to do this for CTEs too, but that would be a
    significantly more invasive patch because the sub-PlannerInfo is no longer
    accessible by the time it's needed.  I refrained from doing anything about
    that, partly for fear of breaking the unmerged CTE-related patches.
    
    In passing, also generate less bogus width estimates for whole-row Vars.
    
    Per a gripe from Jon Nelson.
    0f61d4dd
planner.c 97.4 KB