mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-17 11:57:00 +08:00
Introduce a third extended statistic type, supported by the CREATE STATISTICS command - MCV lists, a generalization of the statistic already built and used for individual columns. Compared to the already supported types (n-distinct coefficients and functional dependencies), MCV lists are more complex, include column values and allow estimation of much wider range of common clauses (equality and inequality conditions, IS NULL, IS NOT NULL etc.). Similarly to the other types, a new pseudo-type (pg_mcv_list) is used. Author: Tomas Vondra Reviewed-by: Dean Rasheed, David Rowley, Mark Dilger, Alvaro Herrera Discussion: https://postgr.es/m/dfdac334-9cf2-2597-fb27-f0fb3753f435@2ndquadrant.com
73 lines
2.0 KiB
C
73 lines
2.0 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* pg_statistic_ext.h
|
|
* definition of the "extended statistics" system catalog (pg_statistic_ext)
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/catalog/pg_statistic_ext.h
|
|
*
|
|
* NOTES
|
|
* The Catalog.pm module reads this file and derives schema
|
|
* information.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PG_STATISTIC_EXT_H
|
|
#define PG_STATISTIC_EXT_H
|
|
|
|
#include "catalog/genbki.h"
|
|
#include "catalog/pg_statistic_ext_d.h"
|
|
|
|
/* ----------------
|
|
* pg_statistic_ext definition. cpp turns this into
|
|
* typedef struct FormData_pg_statistic_ext
|
|
* ----------------
|
|
*/
|
|
CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
|
|
{
|
|
Oid oid; /* oid */
|
|
|
|
Oid stxrelid; /* relation containing attributes */
|
|
|
|
/* These two fields form the unique key for the entry: */
|
|
NameData stxname; /* statistics object name */
|
|
Oid stxnamespace; /* OID of statistics object's namespace */
|
|
|
|
Oid stxowner; /* statistics object's owner */
|
|
|
|
/*
|
|
* variable-length fields start here, but we allow direct access to
|
|
* stxkeys
|
|
*/
|
|
int2vector stxkeys; /* array of column keys */
|
|
|
|
#ifdef CATALOG_VARLEN
|
|
char stxkind[1] BKI_FORCE_NOT_NULL; /* statistics kinds requested
|
|
* to build */
|
|
pg_ndistinct stxndistinct; /* ndistinct coefficients (serialized) */
|
|
pg_dependencies stxdependencies; /* dependencies (serialized) */
|
|
pg_mcv_list stxmcv; /* MCV (serialized) */
|
|
#endif
|
|
|
|
} FormData_pg_statistic_ext;
|
|
|
|
/* ----------------
|
|
* Form_pg_statistic_ext corresponds to a pointer to a tuple with
|
|
* the format of pg_statistic_ext relation.
|
|
* ----------------
|
|
*/
|
|
typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
|
|
|
|
#ifdef EXPOSE_TO_CLIENT_CODE
|
|
|
|
#define STATS_EXT_NDISTINCT 'd'
|
|
#define STATS_EXT_DEPENDENCIES 'f'
|
|
#define STATS_EXT_MCV 'm'
|
|
|
|
#endif /* EXPOSE_TO_CLIENT_CODE */
|
|
|
|
#endif /* PG_STATISTIC_EXT_H */
|