• Tom Lane's avatar
    Tweak genericcostestimate's fudge factor for index size. · bf01e34b
    Tom Lane authored
    To provide some bias against using a large index when a small one would do
    as well, genericcostestimate adds a "fudge factor", which for a long time
    was random_page_cost * index_pages/10000.  However, this can grow to be the
    dominant term in indexscan cost estimates when the index involved is large
    enough, a behavior that was never intended.  Change to a ln(1 + n/10000)
    formulation, which has nearly the same behavior up to a few hundred pages
    but tails off significantly thereafter.  (A log curve seems correct on
    first principles, since what we're trying to account for here is index
    descent costs, which are typically logarithmic.)  Per bug #7619 from Niko
    Kiirala.
    
    Possibly this change should get back-patched, but I'm hesitant to mess with
    cost estimates in stable branches.
    bf01e34b
selfuncs.c 205 KB