23 #include "utils/fmgroids.h"
50 bool use_extended_stats);
107 jointype, sjinfo,
true);
122 bool use_extended_stats)
137 varRelid, jointype, sjinfo,
154 jointype, sjinfo, rel,
155 &estimatedclauses,
false);
195 if (rinfo->pseudoconstant)
214 bool varonleft =
true;
219 ok = (rinfo->num_base_rels == 1) &&
221 rinfo->right_relids) ||
224 rinfo->left_relids)));
246 varonleft,
true,
s2);
251 varonleft,
false,
s2);
269 while (rqlist != NULL)
294 varRelid, jointype, sjinfo);
336 rqnext = rqlist->
next;
364 bool use_extended_stats)
386 jointype, sjinfo, rel,
387 &estimatedclauses,
true);
413 jointype, sjinfo, use_extended_stats);
437 is_lobound = !isLTsel;
442 is_lobound = isLTsel;
445 for (rqelem = *rqlist; rqelem; rqelem = rqelem->
next)
512 rqelem->
next = *rqlist;
554 lastrelid = rel->
relid;
555 else if (rel->
relid != lastrelid)
570 else if (relid != lastrelid)
597 else if (sjinfo == NULL)
621 return (rinfo->num_base_rels > 1);
674 jointype, sjinfo,
true);
689 bool use_extended_stats)
693 bool cacheable =
false;
710 if (rinfo->pseudoconstant)
728 rinfo->num_base_rels == 0 ||
729 (rinfo->num_base_rels == 1 &&
735 if (rinfo->norm_selec >= 0)
736 return rinfo->norm_selec;
740 if (rinfo->outer_selec >= 0)
741 return rinfo->outer_selec;
752 clause = (
Node *) rinfo->orclause;
765 if (
var->varlevelsup == 0 &&
766 (varRelid == 0 || varRelid == (
int)
var->varno))
777 s1 = con->constisnull ? 0.0 :
790 s1 = con->constisnull ? 0.0 :
841 opclause->inputcollid,
850 opclause->inputcollid,
871 funcclause->inputcollid,
902 ((
NullTest *) clause)->nulltesttype,
963 rinfo->norm_selec =
s1;
965 rinfo->outer_selec =
s1;
968 #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)
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