• Alvaro Herrera's avatar
    Allow direct lookups of AppendRelInfo by child relid · 7d872c91
    Alvaro Herrera authored
    find_appinfos_by_relids had quite a large overhead when the number of
    items in the append_rel_list was high, as it had to trawl through the
    append_rel_list looking for AppendRelInfos belonging to the given
    childrelids.  Since there can only be a single AppendRelInfo for each
    child rel, it seems much better to store an array in PlannerInfo which
    indexes these by child relid, making the function O(1) rather than O(N).
    This function was only called once inside the planner, so just replace
    that call with a lookup to the new array.  find_childrel_appendrelinfo
    is now unused and thus removed.
    
    This fixes a planner performance regression new to v11 reported by
    Thomas Reiss.
    
    Author: David Rowley
    Reported-by: Thomas Reiss
    Reviewed-by: Ashutosh Bapat
    Reviewed-by: Álvaro Herrera
    Discussion: https://postgr.es/m/94dd7a4b-5e50-0712-911d-2278e055c622@dalibo.com
    7d872c91
planmain.c 9.03 KB