MobilityDB 1.3
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
span_selfuncs.c File Reference

Functions for selectivity estimation of span types. More...

#include "pg_temporal/span_selfuncs.h"
#include <assert.h>
#include <access/htup_details.h>
#include "utils/syscache.h"
#include <utils/lsyscache.h>
#include <catalog/pg_statistic.h>
#include <meos.h>
#include <meos_internal.h>
#include "temporal/set.h"
#include "temporal/span.h"
#include "pg_temporal/meos_catalog.h"
#include "pg_temporal/span_analyze.h"
#include "pg_temporal/temporal_selfuncs.h"

Functions

Datum _mobdb_span_joinsel (PG_FUNCTION_ARGS)
 Utility function to read the calculated selectivity for a given couple of table/column, and operator. More...
 
Datum _mobdb_span_sel (PG_FUNCTION_ARGS)
 Utility function to read the calculated selectivity for a given table/column, operator, and search span. More...
 
double calc_length_hist_frac (Datum *hist_length, int hist_length_nvalues, double length1, double length2, bool equal)
 Calculate the average of function P(x), in the interval [length1, length2], where P(x) is the fraction of tuples with length < x (or length <= x if 'equal' is true) More...
 
double get_len_position (double value, double hist1, double hist2)
 Get relative position of a value in a length histogram bin in a [0,1] range. More...
 
int length_hist_bsearch (Datum *hist_length, int hist_length_nvalues, double value, bool equal)
 Binary search on length histogram. More...
 
static int span_bound_bsearch (const SpanBound *value, const SpanBound *hist, int hist_nvalues, bool equal)
 Binary search on an array of span bounds. More...
 
static float8 span_bound_distance (const SpanBound *bound1, const SpanBound *bound2)
 Measure distance between two span bounds. More...
 
void span_const_to_span (Node *other, Span *span)
 Transform the constant into a span. More...
 
Datum Span_joinsel (PG_FUNCTION_ARGS)
 Join selectivity for spans. More...
 
Selectivity span_joinsel (PlannerInfo *root, bool value, meosOper oper, List *args, JoinType jointype UNUSED, SpecialJoinInfo *sjinfo)
 Estimate join selectivity for spans. More...
 
float8 span_joinsel_default (meosOper oper UNUSED)
 Return a default join selectivity estimate for given operator, when we don't have statistics or cannot use them for some reason. More...
 
static Selectivity span_joinsel_hist (VariableStatData *vardata1, VariableStatData *vardata2, bool value, meosOper oper)
 Calculate span operator selectivity using histograms of span bounds. More...
 
static Selectivity span_joinsel_hist1 (AttStatsSlot *hslot1, AttStatsSlot *hslot2, AttStatsSlot *lslot, meosOper oper)
 Calculate span operator selectivity using histograms of span bounds. More...
 
static Selectivity span_joinsel_oper (SpanBound *lower1, SpanBound *upper1, int nhist1, SpanBound *lower2, SpanBound *upper2, int nhist2, Datum *length, int length_nvalues, meosOper oper)
 Look up the fraction of values in the first histogram that satisfy an operator with respect to a value in the second histogram. More...
 
static Selectivity span_joinsel_scalar (const SpanBound *hist1, int nhist1, const SpanBound *hist2, int nhist2, bool equal UNUSED)
 
static float8 span_position (const SpanBound *value, const SpanBound *hist1, const SpanBound *hist2)
 Get relative position of value in histogram bin in [0,1] span. More...
 
Datum Span_sel (PG_FUNCTION_ARGS)
 Restriction selectivity for span operators. More...
 
Selectivity span_sel (PlannerInfo *root, Oid operid, List *args, int varRelid)
 Restriction selectivity for span operators. More...
 
static double span_sel_contained (SpanBound *const_lower, SpanBound *const_upper, SpanBound *hist_lower, int hist_nvalues, Datum *hist_length, int hist_length_nvalues)
 Calculate selectivity of "var <@ const" operator, i.e., estimate the fraction of spans that fall within the constant lower and upper bounds. More...
 
static double span_sel_contains (SpanBound *const_lower, SpanBound *const_upper, SpanBound *hist_lower, int hist_nvalues, Datum *hist_length, int hist_length_nvalues)
 Calculate selectivity of "var @> const" operator, i.e., estimate the fraction of spans that contain the constant lower and upper bounds. More...
 
float8 span_sel_default (meosOper oper UNUSED)
 Return a default selectivity estimate for given operator, when we don't have statistics or cannot use them for some reason. More...
 
Selectivity span_sel_hist (VariableStatData *vardata, const Span *constval, meosOper oper, bool value)
 Calculate span operator selectivity using histograms of span bounds. More...
 
static Selectivity span_sel_hist1 (AttStatsSlot *hslot, AttStatsSlot *lslot, const Span *constval, meosOper oper)
 Calculate span operator selectivity using histograms of span bounds. More...
 
static Selectivity span_sel_overlaps (const SpanBound *const_lower, const SpanBound *const_upper, const SpanBound *hist_lower, const SpanBound *hist_upper, int nhist)
 Calculate the selectivity of "var && const" operator, i.e., estimate the fraction of spans that overlap the constant lower and upper bounds using the histograms of span lower and upper bounds. More...
 
static Selectivity span_sel_scalar (const SpanBound *constbound, const SpanBound *hist, int nhist, bool equal)
 Estimate the fraction of values less than (or equal to, if 'equal' argument is true) a given const in a histogram of span bounds. More...
 
bool time_oper_sel (meosOper oper UNUSED, meosType ltype, meosType rtype)
 Determine whether we can estimate selectivity for the operator. More...
 
static bool value_oper_sel (Oid operid UNUSED, meosType ltype, meosType rtype)
 Determine whether we can estimate selectivity for the operator. More...
 

Detailed Description

Functions for selectivity estimation of span types.

These functions are based on those of the file rangetypes_selfuncs.c. Estimates are based on histograms of lower and upper bounds.