• T
    Make the planner estimate costs for nestloop inner indexscans on the basis · 8a30cc21
    Tom Lane 提交于
    that the Mackert-Lohmann formula applies across all the repetitions of the
    nestloop, not just each scan independently.  We use the M-L formula to
    estimate the number of pages fetched from the index as well as from the table;
    that isn't what it was designed for, but it seems reasonably applicable
    anyway.  This makes large numbers of repetitions look much cheaper than
    before, which accords with many reports we've received of overestimation
    of the cost of a nestloop.  Also, change the index access cost model to
    charge random_page_cost per index leaf page touched, while explicitly
    not counting anything for access to metapage or upper tree pages.  This
    may all need tweaking after we get some field experience, but in simple
    tests it seems to be giving saner results than before.  The main thing
    is to get the infrastructure in place to let cost_index() and amcostestimate
    functions take repeated scans into account at all.  Per my recent proposal.
    
    Note: this patch changes pg_proc.h, but I did not force initdb because
    the changes are basically cosmetic --- the system does not look into
    pg_proc to decide how to call an index amcostestimate function, and
    there's no way to call such a function from SQL at all.
    8a30cc21
planagg.c 17.1 KB