MobilityDB 1.1
tpoint_selfuncs.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2023, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
27 *
28 *****************************************************************************/
29
34#ifndef __TPOINT_SELFUNCS_H__
35#define __TPOINT_SELFUNCS_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39#include <catalog/pg_statistic.h>
40#include <utils/selfuncs.h>
41/* MEOS */
42#include "general/meos_catalog.h"
43#include "point/tpoint.h"
44/* MobilityDB */
46
52#define X_DIM 0
53#define Y_DIM 1
54#define Z_DIM 2
55#define T_DIM 3
56#define ND_DIMS 4
57
58/*****************************************************************************
59 * Definitions copied from PostGIS file gserialized_estimate.c
60 *****************************************************************************/
61
62/*
63* The SD factor restricts the side of the statistics histogram
64* based on the standard deviation of the extent of the data.
65* SDFACTOR is the number of standard deviations from the mean
66* the histogram will extend.
67*/
68#define SDFACTOR 3.25
69
76#define MIN_DIMENSION_WIDTH 0.000000001
77
78#define STATISTIC_KIND_ND 102
79#define STATISTIC_KIND_2D 103
80#define STATISTIC_SLOT_ND 0
81#define STATISTIC_SLOT_2D 1
82
86#define DEFAULT_ND_SEL 0.0001
87#define DEFAULT_ND_JOINSEL 0.001
88
92#define FALLBACK_ND_SEL 0.2
93#define FALLBACK_ND_JOINSEL 0.3
94
95/*****************************************************************************/
96
97extern ND_STATS *pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode);
98extern ND_STATS *pg_get_nd_stats(const Oid tableid, AttrNumber att_num,
99 int mode, bool only_parent);
100
101extern float8 geo_sel(VariableStatData *vardata, const STBox *box,
102 meosOper oper);
103extern float8 geo_joinsel(const ND_STATS *s1, const ND_STATS *s2);
104
105/*****************************************************************************/
106
107#endif
double float8
Definition: c.h:570
meosOper
Enumeration that defines the classes of Boolean operators used in MobilityDB.
Definition: meos_catalog.h:107
unsigned int Oid
Definition: postgres_ext.h:31
N-dimensional statistics structure.
Definition: tpoint_analyze.h:79
Structure to represent spatiotemporal boxes.
Definition: meos.h:107
float8 geo_sel(VariableStatData *vardata, const STBox *box, meosOper oper)
Return an estimate of the selectivity of a spatiotemporal search box by looking at data in the ND_STA...
Definition: tpoint_selfuncs.c:491
ND_STATS * pg_get_nd_stats(const Oid tableid, AttrNumber att_num, int mode, bool only_parent)
Pull the stats object from the PgSQL system catalogs.
Definition: tpoint_selfuncs.c:721
float8 geo_joinsel(const ND_STATS *s1, const ND_STATS *s2)
Given two statistics histograms, what is the selectivity of a join driven by the && operator?
Definition: tpoint_selfuncs.c:755
ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)
Get the statistics from the tuple.
Definition: tpoint_selfuncs.c:690