↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Documentation / Extension Hooks / Statistics and estimation

get_index_stats_hook

get_index_stats_hook

get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below.

Reading PostgreSQL 18.

Description

get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below.

Interface type
get_index_stats_hook_type
Header
src/include/utils/selfuncs.h
Subsystem
Statistics and estimation
Initial value
NULL (no hook installed)

C interface

typedef bool (*get_index_stats_hook_type) (PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata);
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;

Call sites

src/backend/utils/adt/selfuncs.c:5488

src/backend/utils/adt/selfuncs.c:6224

src/backend/utils/adt/selfuncs.c:8783

Core call context: src/backend/utils/adt/selfuncs.c:5482–5496

						 * a partial index.
						 *
						 * An index stats hook, however, must make its own
						 * decisions about what to do with partial indexes.
						 */
						if (get_index_stats_hook &&
							(*get_index_stats_hook) (root, index->indexoid,
													 pos + 1, vardata))
						{
							/*
							 * The hook took control of acquiring a stats
							 * tuple.  If it did supply a tuple, it'd better
							 * have supplied a freefunc.
							 */
							if (HeapTupleIsValid(vardata->statsTuple) &&

Core call context: src/backend/utils/adt/selfuncs.c:6218–6232

	{
		/* Expression --- maybe there are stats for the index itself */
		relid = index->indexoid;
		colnum = indexcol + 1;

		if (get_index_stats_hook &&
			(*get_index_stats_hook) (root, relid, colnum, vardata))
		{
			/*
			 * The hook took control of acquiring a stats tuple.  If it did
			 * supply a tuple, it'd better have supplied a freefunc.
			 */
			if (HeapTupleIsValid(vardata->statsTuple) &&
				!vardata->freefunc)
				elog(ERROR, "no function provided to release variable stats with");

Core call context: src/backend/utils/adt/selfuncs.c:8777–8791

			 */

			/* get the attnum from the 0-based index. */
			attnum = iclause->indexcol + 1;

			if (get_index_stats_hook &&
				(*get_index_stats_hook) (root, index->indexoid, attnum, &vardata))
			{
				/*
				 * The hook took control of acquiring a stats tuple.  If it
				 * did supply a tuple, it'd better have supplied a freefunc.
				 */
				if (HeapTupleIsValid(vardata.statsTuple) &&
					!vardata.freefunc)
					elog(ERROR, "no function provided to release variable stats with");

Related entries

Documentation and source

Source build
Version
18
Build
REL_18_STABLE
Source fingerprint
753057e340da8f22e57c9a409ea7a235fd6a46bd

Related entries

Back to Extension Hooks · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.