pgsql: Make gincostestimate() cope with hypothetical GIN indexes. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Make gincostestimate() cope with hypothetical GIN indexes.
Date
Msg-id E1a3sPv-0006aj-8V@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Make gincostestimate() cope with hypothetical GIN indexes.

We tried to fetch statistics data from the index metapage, which does not
work if the index isn't actually present.  If the index is hypothetical,
instead extrapolate some plausible internal statistics based on the index
page count provided by the index-advisor plugin.

There was already some code in gincostestimate() to invent internal stats
in this way, but since it was only meant as a stopgap for pre-9.1 GIN
indexes that hadn't been vacuumed since upgrading, it was pretty crude.
If we want it to support index advisors, we should try a little harder.
A small amount of testing says that it's better to estimate the entry pages
as 90% of the index, not 100%.  Also, estimating the number of entries
(keys) as equal to the heap tuple count could be wildly wrong in either
direction.  Instead, let's estimate 100 entries per entry page.

Perhaps someday somebody will want the index advisor to be able to provide
these numbers more directly, but for the moment this should serve.

Problem report and initial patch by Julien Rouhaud; modified by me to
invent less-bogus internal statistics.  Back-patch to all supported
branches, since we've supported index advisors since 9.0.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/3d4bdd2f94a40a4fd5ea43d80d0bd262b280b033

Modified Files
--------------
src/backend/utils/adt/selfuncs.c |   58 +++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 20 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Make gincostestimate() cope with hypothetical GIN indexes.
Next
From: Tom Lane
Date:
Subject: pgsql: Make gincostestimate() cope with hypothetical GIN indexes.