pgsql: Clean up the loose ends in selectivity estimation left by my

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Clean up the loose ends in selectivity estimation left by my
Date: 2008-08-16 00:01:38
Message-ID: 20080816000138.99A13755315@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Clean up the loose ends in selectivity estimation left by my patch for semi
and anti joins. To do this, pass the SpecialJoinInfo struct for the current
join as an additional optional argument to operator join selectivity
estimation functions. This allows the estimator to tell not only what kind
of join is being formed, but which variable is on which side of the join;
a requirement long recognized but not dealt with till now. This also leaves
the door open for future improvements in the estimators, such as accounting
for the null-insertion effects of lower outer joins. I didn't do anything
about that in the current patch but the information is in principle deducible
from what's passed.

The patch also clarifies the definition of join selectivity for semi/anti
joins: it's the fraction of the left input that has (at least one) match
in the right input. This allows getting rid of some very fuzzy thinking
that I had committed in the original 7.4-era IN-optimization patch.
There's probably room to estimate this better than the present patch does,
but at least we know what to estimate.

Since I had to touch CREATE OPERATOR anyway to allow a variant signature
for join estimator functions, I took the opportunity to add a couple of
additional checks that were missing, per my recent message to -hackers:
* Check that estimator functions return float8;
* Require execute permission at the time of CREATE OPERATOR on the
operator's function as well as the estimator functions;
* Require ownership of any pre-existing operator that's modified by
the command.
I also moved the lookup of the functions out of OperatorCreate() and
into operatorcmds.c, since that seemed more consistent with most of
the other catalog object creation processes, eg CREATE TYPE.

Modified Files:
--------------
pgsql/src/backend/catalog:
pg_operator.c (r1.104 -> r1.105)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/pg_operator.c?r1=1.104&r2=1.105)
pgsql/src/backend/commands:
operatorcmds.c (r1.40 -> r1.41)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/operatorcmds.c?r1=1.40&r2=1.41)
pgsql/src/backend/optimizer/path:
clausesel.c (r1.91 -> r1.92)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/clausesel.c?r1=1.91&r2=1.92)
costsize.c (r1.193 -> r1.194)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/costsize.c?r1=1.193&r2=1.194)
pgsql/src/backend/optimizer/util:
plancat.c (r1.148 -> r1.149)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/plancat.c?r1=1.148&r2=1.149)
pgsql/src/backend/utils/adt:
selfuncs.c (r1.251 -> r1.252)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/selfuncs.c?r1=1.251&r2=1.252)
pgsql/src/include/catalog:
catversion.h (r1.477 -> r1.478)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.477&r2=1.478)
pg_operator.h (r1.161 -> r1.162)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_operator.h?r1=1.161&r2=1.162)
pg_proc.h (r1.509 -> r1.510)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h?r1=1.509&r2=1.510)
pgsql/src/include/optimizer:
plancat.h (r1.50 -> r1.51)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/plancat.h?r1=1.50&r2=1.51)
pgsql/src/include/utils:
selfuncs.h (r1.45 -> r1.46)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/selfuncs.h?r1=1.45&r2=1.46)
pgsql/src/test/regress/expected:
opr_sanity.out (r1.83 -> r1.84)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/opr_sanity.out?r1=1.83&r2=1.84)
pgsql/src/test/regress/sql:
opr_sanity.sql (r1.67 -> r1.68)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/opr_sanity.sql?r1=1.67&r2=1.68)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2008-08-16 00:16:56 pgsql: Fix version warning bug in recently applied adjustments to psql
Previous Message Tom Lane 2008-08-15 19:20:42 pgsql: Performance fix for new anti-join code in nodeMergejoin.c: after