Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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:
        pg_operator.c (r1.104 -> r1.105)
        operatorcmds.c (r1.40 -> r1.41)
        clausesel.c (r1.91 -> r1.92)
        costsize.c (r1.193 -> r1.194)
        plancat.c (r1.148 -> r1.149)
        selfuncs.c (r1.251 -> r1.252)
        catversion.h (r1.477 -> r1.478)
        pg_operator.h (r1.161 -> r1.162)
        pg_proc.h (r1.509 -> r1.510)
        plancat.h (r1.50 -> r1.51)
        selfuncs.h (r1.45 -> r1.46)
        opr_sanity.out (r1.83 -> r1.84)
        opr_sanity.sql (r1.67 -> r1.68)

pgsql-committers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group