pgsql: Make the planner estimate costs for nestloop inner indexscans on - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Make the planner estimate costs for nestloop inner indexscans on
Date
Msg-id 20060606175958.7A85B9FB1B9@postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
Make the planner estimate costs for nestloop inner indexscans on the basis
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.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        indexam.sgml (r2.13 -> r2.14)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/indexam.sgml.diff?r1=2.13&r2=2.14)
    pgsql/src/backend/optimizer/path:
        costsize.c (r1.157 -> r1.158)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/costsize.c.diff?r1=1.157&r2=1.158)
        indxpath.c (r1.206 -> r1.207)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/indxpath.c.diff?r1=1.206&r2=1.207)
        joinpath.c (r1.103 -> r1.104)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/joinpath.c.diff?r1=1.103&r2=1.104)
        orindxpath.c (r1.78 -> r1.79)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/orindxpath.c.diff?r1=1.78&r2=1.79)
    pgsql/src/backend/optimizer/plan:
        planagg.c (r1.14 -> r1.15)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/planagg.c.diff?r1=1.14&r2=1.15)
    pgsql/src/backend/optimizer/util:
        pathnode.c (r1.127 -> r1.128)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/pathnode.c.diff?r1=1.127&r2=1.128)
    pgsql/src/backend/utils/adt:
        selfuncs.c (r1.206 -> r1.207)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/selfuncs.c.diff?r1=1.206&r2=1.207)
    pgsql/src/include/catalog:
        pg_proc.h (r1.412 -> r1.413)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h.diff?r1=1.412&r2=1.413)
    pgsql/src/include/nodes:
        relation.h (r1.124 -> r1.125)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/relation.h.diff?r1=1.124&r2=1.125)
    pgsql/src/include/optimizer:
        cost.h (r1.75 -> r1.76)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/cost.h.diff?r1=1.75&r2=1.76)
        pathnode.h (r1.67 -> r1.68)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/pathnode.h.diff?r1=1.67&r2=1.68)
        paths.h (r1.92 -> r1.93)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/paths.h.diff?r1=1.92&r2=1.93)
    pgsql/src/include:
        pg_config_manual.h (r1.21 -> r1.22)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/pg_config_manual.h.diff?r1=1.21&r2=1.22)

pgsql-committers by date:

Previous
From: momjian@postgresql.org (Bruce Momjian)
Date:
Subject: pgsql: Add URL to RESET CONNECTION: < notify the protocol when a
Next
From: momjian@postgresql.org (Bruce Momjian)
Date:
Subject: pgsql: On Win32, return original patch if GetShortPathName() fails (no