PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/htup_details.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_statistic.h"
#include "utils/array.h"
#include "utils/fmgrprotos.h"
#include "utils/lsyscache.h"
#include "utils/selfuncs.h"
#include "utils/typcache.h"
Go to the source code of this file.
Macros | |
#define | DEFAULT_CONTAIN_SEL 0.005 |
#define | DEFAULT_OVERLAP_SEL 0.01 |
#define | DEFAULT_SEL(operator) |
#define | EFFORT 100 |
Functions | |
static Selectivity | calc_arraycontsel (VariableStatData *vardata, Datum constval, Oid elemtype, Oid operator) |
static Selectivity | mcelem_array_selec (ArrayType *array, TypeCacheEntry *typentry, Datum *mcelem, int nmcelem, float4 *numbers, int nnumbers, float4 *hist, int nhist, Oid operator) |
static Selectivity | mcelem_array_contain_overlap_selec (Datum *mcelem, int nmcelem, float4 *numbers, int nnumbers, Datum *array_data, int nitems, Oid operator, TypeCacheEntry *typentry) |
static Selectivity | mcelem_array_contained_selec (Datum *mcelem, int nmcelem, float4 *numbers, int nnumbers, Datum *array_data, int nitems, float4 *hist, int nhist, Oid operator, TypeCacheEntry *typentry) |
static float * | calc_hist (const float4 *hist, int nhist, int n) |
static float * | calc_distr (const float *p, int n, int m, float rest) |
static int | floor_log2 (uint32 n) |
static bool | find_next_mcelem (Datum *mcelem, int nmcelem, Datum value, int *index, TypeCacheEntry *typentry) |
static int | element_compare (const void *key1, const void *key2, void *arg) |
static int | float_compare_desc (const void *key1, const void *key2) |
Selectivity | scalararraysel_containment (PlannerInfo *root, Node *leftop, Node *rightop, Oid elemtype, bool isEquality, bool useOr, int varRelid) |
Datum | arraycontsel (PG_FUNCTION_ARGS) |
Datum | arraycontjoinsel (PG_FUNCTION_ARGS) |
#define DEFAULT_CONTAIN_SEL 0.005 |
Definition at line 30 of file array_selfuncs.c.
#define DEFAULT_OVERLAP_SEL 0.01 |
Definition at line 33 of file array_selfuncs.c.
#define DEFAULT_SEL | ( | operator | ) |
Definition at line 36 of file array_selfuncs.c.
#define EFFORT 100 |
Datum arraycontjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 321 of file array_selfuncs.c.
References DEFAULT_SEL, PG_GETARG_OID, and PG_RETURN_FLOAT8.
Referenced by _int_contained_joinsel(), _int_contains_joinsel(), and _int_overlap_joinsel().
Datum arraycontsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 241 of file array_selfuncs.c.
References generate_unaccent_rules::args, calc_arraycontsel(), CLAMP_PROBABILITY, DEFAULT_SEL, get_base_element_type(), get_restriction_variable(), InvalidOid, IsA, PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, ReleaseVariableStats, root, and VariableStatData::vartype.
Referenced by _int_contained_sel(), _int_contains_sel(), and _int_overlap_sel().
|
static |
Definition at line 337 of file array_selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, TypeCacheEntry::cmp_proc_finfo, DatumGetArrayTypeP, DEFAULT_SEL, FmgrInfo::fn_oid, free_attstatsslot(), get_attstatsslot(), GETSTRUCT, HeapTupleIsValid, InvalidOid, lookup_type_cache(), mcelem_array_selec(), AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::nvalues, OidIsValid, pfree(), PointerGetDatum(), statistic_proc_security_check(), VariableStatData::statsTuple, TYPECACHE_CMP_PROC_FINFO, and AttStatsSlot::values.
Referenced by arraycontsel().
|
static |
Definition at line 1010 of file array_selfuncs.c.
References DEFAULT_CONTAIN_SEL, i, j, palloc(), pfree(), and val.
Referenced by mcelem_array_contained_selec().
|
static |
Definition at line 921 of file array_selfuncs.c.
References i, palloc(), and val.
Referenced by mcelem_array_contained_selec().
|
static |
Definition at line 1165 of file array_selfuncs.c.
References arg, TypeCacheEntry::cmp_proc_finfo, DatumGetInt32(), FunctionCall2Coll(), and TypeCacheEntry::typcollation.
Referenced by find_next_mcelem(), mcelem_array_contain_overlap_selec(), mcelem_array_contained_selec(), and mcelem_array_selec().
|
static |
Definition at line 1130 of file array_selfuncs.c.
References element_compare(), i, res, and value.
Referenced by mcelem_array_contain_overlap_selec().
|
static |
|
static |
Definition at line 1089 of file array_selfuncs.c.
Referenced by mcelem_array_contain_overlap_selec().
|
static |
Definition at line 521 of file array_selfuncs.c.
References CLAMP_PROBABILITY, cmp(), DEFAULT_CONTAIN_SEL, element_compare(), find_next_mcelem(), floor_log2(), i, Min, and nitems.
Referenced by mcelem_array_selec(), and scalararraysel_containment().
|
static |
Definition at line 696 of file array_selfuncs.c.
References b, calc_distr(), calc_hist(), CLAMP_PROBABILITY, cmp(), DEFAULT_CONTAIN_SEL, EFFORT, element_compare(), float_compare_desc(), i, Min, nitems, palloc(), pfree(), and qsort.
Referenced by mcelem_array_selec(), and scalararraysel_containment().
|
static |
Definition at line 428 of file array_selfuncs.c.
References deconstruct_array(), element_compare(), elog, ERROR, i, mcelem_array_contain_overlap_selec(), mcelem_array_contained_selec(), pfree(), qsort_arg(), TypeCacheEntry::typalign, TypeCacheEntry::typbyval, TypeCacheEntry::type_id, and TypeCacheEntry::typlen.
Referenced by calc_arraycontsel().
Selectivity scalararraysel_containment | ( | PlannerInfo * | root, |
Node * | leftop, | ||
Node * | rightop, | ||
Oid | elemtype, | ||
bool | isEquality, | ||
bool | useOr, | ||
int | varRelid | ||
) |
Definition at line 81 of file array_selfuncs.c.
References ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, CLAMP_PROBABILITY, TypeCacheEntry::cmp_proc_finfo, examine_variable(), FmgrInfo::fn_oid, free_attstatsslot(), get_attstatsslot(), GETSTRUCT, HeapTupleIsValid, InvalidOid, IsA, lookup_type_cache(), mcelem_array_contain_overlap_selec(), mcelem_array_contained_selec(), AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::nvalues, OidIsValid, VariableStatData::rel, ReleaseVariableStats, root, statistic_proc_security_check(), VariableStatData::statsTuple, TYPECACHE_CMP_PROC_FINFO, and AttStatsSlot::values.
Referenced by scalararraysel().