pgsql: Allow estimate_num_groups() to pass back further details about t - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Allow estimate_num_groups() to pass back further details about t
Date
Msg-id E1lR9CA-0007FU-9b@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Allow estimate_num_groups() to pass back further details about the estimation

Here we add a new output parameter to estimate_num_groups() to allow it to
inform the caller of additional, possibly useful information about the
estimation.

The new output parameter is a struct that currently contains just a single
field with a set of flags.  This was done rather than having the flags as
an output parameter to allow future fields to be added without having to
change the signature of the function at a later date when we want to pass
back further information that might not be suitable to store in the flags
field.

It seems reasonable that one day in the future that the planner would want
to know more about the estimation. For example, how many individual sets
of statistics was the estimation generated from?  The planner may want to
take that into account if we ever want to consider risks as well as costs
when generating plans.

For now, there's only 1 flag we set in the flags field.  This is to
indicate if the estimation fell back on using the hard-coded constants in
any part of the estimation. Callers may like to change their behavior if
this is set, and this gives them the ability to do so.  Callers may pass
the flag pointer as NULL if they have no interest in obtaining any
additional information about the estimate.

We're not adding any actual usages of these flags here.  Some follow-up
commits will make use of this feature.  Additionally, we're also not
making any changes to add support for clauselist_selectivity() and
clauselist_selectivity_ext().  However, if this is required in the future
then the same struct being added here should be fine to use as a new
output argument for those functions too.

Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvqQqpk=1W-G_ds7A9CsXX3BggWj_7okinzkLVhDubQzjA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ed934d4fa30f0f94e6f7125ad2154e6a58d1c7f7

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c    |  2 +-
src/backend/optimizer/path/costsize.c  |  3 ++-
src/backend/optimizer/path/indxpath.c  |  1 +
src/backend/optimizer/plan/planner.c   | 10 ++++++----
src/backend/optimizer/prep/prepunion.c |  1 +
src/backend/optimizer/util/pathnode.c  |  1 +
src/backend/utils/adt/selfuncs.c       | 22 +++++++++++++++++++++-
src/include/utils/selfuncs.h           | 17 ++++++++++++++++-
8 files changed, 49 insertions(+), 8 deletions(-)


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Fix compiler warning in unistr function
Next
From: Tom Lane
Date:
Subject: pgsql: Further tweaking of pg_dump's handling of default_toast_compress