![]() |
MobilityDB 1.3
|
Create a cache of PostgreSQL type and operator Oids in global variable arrays to avoid (slow) lookups. More...
#include "pg_temporal/meos_catalog.h"
#include <postgres.h>
#include <miscadmin.h>
#include <access/genam.h>
#include <access/heapam.h>
#include <access/htup_details.h>
#include <access/tableam.h>
#include <catalog/indexing.h>
#include <catalog/namespace.h>
#include <catalog/pg_extension.h>
#include <commands/extension.h>
#include <common/hashfn.h>
#include <utils/fmgroids.h>
#include <utils/syscache.h>
#include <utils/rel.h>
#include <meos.h>
#include "temporal/meos_catalog.h"
#include "lib/simplehash.h"
Data Structures | |
struct | mobilitydb_constants |
Global variable that states whether the type and operator Oid caches have been initialized. More... | |
struct | oid_oper_entry |
Structure to represent the operator cache hash table. More... | |
Macros | |
#define | SH_DECLARE |
#define | SH_DEFINE |
#define | SH_ELEMENT_TYPE oid_oper_entry |
#define | SH_EQUAL(tb, a, b) a == b |
#define | SH_HASH_KEY(tb, key) hash_bytes_uint32(key) |
#define | SH_KEY oproid |
#define | SH_KEY_TYPE Oid |
#define | SH_PREFIX opertable |
Define a hashtable mapping operator Oids to a structure containing operator and type numbers. More... | |
#define | SH_SCOPE static inline |
Functions | |
meosType | basetype_multirangetype (meosType type) |
Return the range type of a base type. More... | |
meosType | basetype_rangetype (meosType type) |
Return the range type of a base type. More... | |
bool | ensure_range_basetype (meosType type) |
Ensure that a type is a built-in PostgreSQL range type. More... | |
Datum | fill_oid_cache (PG_FUNCTION_ARGS) |
Function executed during the CREATE EXTENSION to precompute the operator cache and store it in table mobilitydb_opcache More... | |
static Oid | get_extension_schema (Oid ext_oid) |
static mobilitydb_constants * | get_mobilitydb_constants () |
static bool | internal_type (const char *typname) |
Determine whether the type is an internal MobilityDB type. More... | |
static void | mobilitydb_initialize_cache () |
Initialize Oid cache. More... | |
static Oid | mobilitydb_nsp_oid () |
Return namespace Oid for the extension. More... | |
int | namestrcmp (Name name, const char *str) |
meosOper | oid_oper (Oid oproid, meosType *ltype, meosType *rtype) |
Fetch from the hash table the operator info. More... | |
meosType | oid_type (Oid typid) |
Fetch from the cache the type number. More... | |
Oid | oper_oid (meosOper oper, meosType lt, meosType rt) |
Fetch from the cache the Oid of an operator. More... | |
bool | range_basetype (meosType type) |
Return true if the type is a base type of a built-in PostgreSQL range type. More... | |
static Oid | RelnameNspGetRelid (const char *relname, Oid nsp_oid) |
Utility call to lookup relation oid given name and nspoid. More... | |
Oid | type_oid (meosType type) |
Fetch from the cache the Oid of a type. More... | |
static Oid | TypenameNspGetTypid (const char *typname, Oid nsp_oid) |
Utility call to lookup type oid given name and nspoid. More... | |
Variables | |
mobilitydb_constants * | MOBILITYDB_CONSTANTS = NULL |
Create a cache of PostgreSQL type and operator Oids in global variable arrays to avoid (slow) lookups.
The arrays are initialized when the extension is loaded.
Estimating the selectivity of Boolean operators is essential for defining efficient queries execution plans. The extension defines several classes of Boolean operators (equal, less than, overlaps, ...), each of which has as left or right arguments a built-in type (such as integer, timestamptz, geometry, ...) or a type defined by the extension (such as tstzspan, tint, ...).
As of January 2023 there are 1470 operators defined in MobilityDB. We need to translate between operator Oid <-> MEOS operator info both ways. For Oid -> MEOS operator we use a hash table with Oid as key. For MEOS operator info -> Oid we use a three-dimensional array containing all possible combinations of operator/left argument/right argument. The invalid combinations are initialized to 0.