25 #include "utils/fmgroids.h"
52 bool use_extended_stats);
109 jointype, sjinfo,
true);
124 bool use_extended_stats)
139 varRelid, jointype, sjinfo,
156 jointype, sjinfo, rel,
157 &estimatedclauses,
false);
197 if (rinfo->pseudoconstant)
216 bool varonleft =
true;
221 ok = (rinfo->num_base_rels == 1) &&
223 rinfo->right_relids) ||
226 rinfo->left_relids)));
248 varonleft,
true,
s2);
253 varonleft,
false,
s2);
271 while (rqlist != NULL)
296 varRelid, jointype, sjinfo);
338 rqnext = rqlist->
next;
366 bool use_extended_stats)
388 jointype, sjinfo, rel,
389 &estimatedclauses,
true);
415 jointype, sjinfo, use_extended_stats);
439 is_lobound = !isLTsel;
444 is_lobound = isLTsel;
447 for (rqelem = *rqlist; rqelem; rqelem = rqelem->
next)
514 rqelem->
next = *rqlist;
556 lastrelid = rel->
relid;
557 else if (rel->
relid != lastrelid)
572 else if (relid != lastrelid)
599 else if (sjinfo == NULL)
623 return (rinfo->num_base_rels > 1);
676 jointype, sjinfo,
true);
691 bool use_extended_stats)
695 bool cacheable =
false;
712 if (rinfo->pseudoconstant)
730 rinfo->num_base_rels == 0 ||
731 (rinfo->num_base_rels == 1 &&
737 if (rinfo->norm_selec >= 0)
738 return rinfo->norm_selec;
742 if (rinfo->outer_selec >= 0)
743 return rinfo->outer_selec;
754 clause = (
Node *) rinfo->orclause;
767 if (
var->varlevelsup == 0 &&
768 (varRelid == 0 || varRelid == (
int)
var->varno))
779 s1 = con->constisnull ? 0.0 :
792 s1 = con->constisnull ? 0.0 :
843 opclause->inputcollid,
852 opclause->inputcollid,
873 funcclause->inputcollid,
904 ((
NullTest *) clause)->nulltesttype,
965 rinfo->norm_selec =
s1;
967 rinfo->outer_selec =
s1;
970 #ifdef SELECTIVITY_DEBUG
bool bms_is_member(int x, const Bitmapset *a)
bool bms_get_singleton_member(const Bitmapset *a, int *member)
int NumRelids(PlannerInfo *root, Node *clause)
bool is_pseudo_constant_clause(Node *clause)
bool is_pseudo_constant_clause_relids(Node *clause, Relids relids)
Node * estimate_expression_value(PlannerInfo *root, Node *node)
static void addRangeClause(RangeQueryClause **rqlist, Node *clause, bool varonleft, bool isLTsel, Selectivity s2)
static RelOptInfo * find_single_rel_for_clauses(PlannerInfo *root, List *clauses)
Selectivity clause_selectivity_ext(PlannerInfo *root, Node *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo, bool use_extended_stats)
Selectivity clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity clauselist_selectivity_ext(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo, bool use_extended_stats)
struct RangeQueryClause RangeQueryClause
static bool treat_as_join_clause(PlannerInfo *root, Node *clause, RestrictInfo *rinfo, int varRelid, SpecialJoinInfo *sjinfo)
static Selectivity clauselist_selectivity_or(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo, bool use_extended_stats)
Selectivity clause_selectivity(PlannerInfo *root, Node *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
elog(ERROR, "%s: %s", p2, msg)
bool equal(const void *a, const void *b)
Selectivity statext_clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo, RelOptInfo *rel, Bitmapset **estimatedclauses, bool is_or)
RegProcedure get_oprrest(Oid opno)
void pfree(void *pointer)
static bool is_andclause(const void *clause)
static Expr * get_notclausearg(const void *notclause)
static bool is_orclause(const void *clause)
static bool is_opclause(const void *clause)
static Node * get_rightop(const void *clause)
static bool is_funcclause(const void *clause)
static bool is_notclause(const void *clause)
static Node * get_leftop(const void *clause)
#define IsA(nodeptr, _type_)
static int list_length(const List *l)
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity function_selectivity(PlannerInfo *root, Oid funcid, List *args, Oid inputcollid, bool is_join, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
static bool DatumGetBool(Datum X)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
Selectivity booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity boolvarsel(PlannerInfo *root, Node *arg, int varRelid)
Selectivity scalararraysel(PlannerInfo *root, ScalarArrayOpExpr *clause, bool is_join_clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity rowcomparesel(PlannerInfo *root, RowCompareExpr *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
#define DEFAULT_RANGE_INEQ_SEL
struct RangeQueryClause * next