MobilityDB 1.3
Loading...
Searching...
No Matches
tspatial_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-2025, 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-2025, 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 __TSPATIAL_SELFUNCS_H__
35#define __TSPATIAL_SELFUNCS_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39#include <catalog/pg_statistic.h>
40#include <utils/selfuncs.h>
41/* MEOS */
42#include "temporal/meos_catalog.h"
43/* MobilityDB */
45
51#define X_DIM 0
52#define Y_DIM 1
53#define Z_DIM 2
54#define T_DIM 3
55#define ND_DIMS 4
56
57/*****************************************************************************
58 * Definitions copied from PostGIS file gserialized_estimate.c
59 *****************************************************************************/
60
61/*
62* The SD factor restricts the side of the statistics histogram
63* based on the standard deviation of the extent of the data.
64* SDFACTOR is the number of standard deviations from the mean
65* the histogram will extend.
66*/
67#define SDFACTOR 3.25
68
75#define MIN_DIMENSION_WIDTH 0.000000001
76
77#define STATISTIC_KIND_ND 102
78#define STATISTIC_KIND_2D 103
79#define STATISTIC_SLOT_ND 0
80#define STATISTIC_SLOT_2D 1
81
85#define DEFAULT_ND_SEL 0.0001
86#define DEFAULT_ND_JOINSEL 0.001
87
91#define FALLBACK_ND_SEL 0.2
92#define FALLBACK_ND_JOINSEL 0.3
93
94/*****************************************************************************/
95
96extern ND_STATS *pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode);
97extern ND_STATS *pg_get_nd_stats(const Oid tableid, AttrNumber att_num,
98 int mode, bool only_parent);
99
100extern float8 geo_sel(VariableStatData *vardata, const STBox *box,
101 meosOper oper);
102extern float8 geo_joinsel(const ND_STATS *s1, const ND_STATS *s2);
103
104/*****************************************************************************/
105
106#endif
double float8
Definition: c.h:581
meosOper
Enumeration that defines the classes of Boolean operators used in MobilityDB.
Definition: meos_catalog.h:128
unsigned int Oid
Definition: postgres_ext.h:31
N-dimensional statistics structure.
Definition: tspatial_analyze.h:79
Structure to represent spatiotemporal boxes.
Definition: meos.h:134
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: tspatial_selfuncs.c:488
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: tspatial_selfuncs.c:718
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: tspatial_selfuncs.c:751
ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)
Get the statistics from a tuple.
Definition: tspatial_selfuncs.c:687