MobilityDB 1.1

◆ span_sel_overlaps()

static double span_sel_overlaps ( const SpanBound const_lower,
const SpanBound const_upper,
const SpanBound hist_lower,
const SpanBound hist_upper,
int  nhist 
)
static

Calculate selectivity of "var && const" operator, i.e., estimate the fraction of spans that overlap the constant lower and upper bounds.

This uses the histograms of span lower and upper bounds.

Note that A && B <=> NOT (A <<# B OR A #>> B).

Since A <<# B and A #>> B are mutually exclusive events we can sum their probabilities to find probability of (A <<# B OR A #>> B).

"(span/spanset) @> timestamptz" is equivalent to "span && [elem,elem]". The caller already constructed the singular span from the element constant, so just treat it the same as &&.