Thread: pgsql: Tweak genericcostestimate's fudge factor for index size.

pgsql: Tweak genericcostestimate's fudge factor for index size.

From
Tom Lane
Date:
Tweak genericcostestimate's fudge factor for index size.

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/bf01e34b556ff37982ba2d882db424aa484c0d07

Modified Files
--------------
src/backend/utils/adt/selfuncs.c |   12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)