{"Entry":{"collection":"hook","key":"get_index_stats_hook","name":"get_index_stats_hook","aliases":[],"metadata":{"aliases":[],"category":"Statistics and estimation","content_hash":"75ec4070d6d5bac73b854afef4a4ff4904e32538dfce309120c0361d4caad41f","imported_at":"2026-09-27T17:57:58.89592+08:00","name":"get_index_stats_hook","name_zh":"get_index_stats_hook","slug":"get_index_stats_hook","summary":"get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below."}},"Definition":{"Collection":"hook","Key":"get_index_stats_hook","SourceDatabase":"center","Version":"18","SourceTable":"hook","SourceKey":"get_index_stats_hook","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","Facts":{"description":["get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below."],"facts":[{"label":"Interface type","value":"get_index_stats_hook_type"},{"label":"Header","value":"src/include/utils/selfuncs.h"},{"label":"Subsystem","value":"Statistics and estimation"},{"label":"Initial value","value":"NULL (no hook installed)"}],"related":[{"label":"The Planner/Optimizer","url":"/docs/18/planner-optimizer.html"}],"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sections":[{"paragraphs":["src/backend/utils/adt/selfuncs.c:5488","src/backend/utils/adt/selfuncs.c:6224","src/backend/utils/adt/selfuncs.c:8783"],"title":"Call sites"},{"code":"\t\t\t\t\t\t * a partial index.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * An index stats hook, however, must make its own\n\t\t\t\t\t\t * decisions about what to do with partial indexes.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t pos + 1, vardata))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * The hook took control of acquiring a stats\n\t\t\t\t\t\t\t * tuple.  If it did supply a tuple, it'd better\n\t\t\t\t\t\t\t * have supplied a freefunc.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:5482–5496"},{"code":"\t{\n\t\t/* Expression --- maybe there are stats for the index itself */\n\t\trelid = index-\u003eindexoid;\n\t\tcolnum = indexcol + 1;\n\n\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t(*get_index_stats_hook) (root, relid, colnum, vardata))\n\t\t{\n\t\t\t/*\n\t\t\t * The hook took control of acquiring a stats tuple.  If it did\n\t\t\t * supply a tuple, it'd better have supplied a freefunc.\n\t\t\t */\n\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026\n\t\t\t\t!vardata-\u003efreefunc)\n\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:6218–6232"},{"code":"\t\t\t */\n\n\t\t\t/* get the attnum from the 0-based index. */\n\t\t\tattnum = iclause-\u003eindexcol + 1;\n\n\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid, attnum, \u0026vardata))\n\t\t\t{\n\t\t\t\t/*\n\t\t\t\t * The hook took control of acquiring a stats tuple.  If it\n\t\t\t\t * did supply a tuple, it'd better have supplied a freefunc.\n\t\t\t\t */\n\t\t\t\tif (HeapTupleIsValid(vardata.statsTuple) \u0026\u0026\n\t\t\t\t\t!vardata.freefunc)\n\t\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:8777–8791"}],"signature":"typedef bool (*get_index_stats_hook_type) (PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata);\nextern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;","sources":[{"label":"Interface declaration","path":"src/include/utils/selfuncs.h","sha256":"a3b64e2dd2d41eab2c162a2571bfbe98fac83ae9fab514b73d637220157a501a","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/selfuncs.h#L147"},{"label":"Core definition","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L149"},{"label":"Call sites","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L5488"}]},"ManualEvidence":{"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sources":[{"label":"Interface declaration","path":"src/include/utils/selfuncs.h","sha256":"a3b64e2dd2d41eab2c162a2571bfbe98fac83ae9fab514b73d637220157a501a","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/selfuncs.h#L147"},{"label":"Core definition","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L149"},{"label":"Call sites","path":"src/backend/utils/adt/selfuncs.c","sha256":"c51b0d3f9c9015e98278241c8efc28c39739a56337ffec1163427b3876170f19","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/selfuncs.c#L5488"}]},"MeasuredEvidence":{}},"Text":{"Collection":"hook","Key":"get_index_stats_hook","SourceDatabase":"center","Version":"18","Locale":"en","Title":"get_index_stats_hook","Summary":"get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below.","BodyHTML":"\u003cp\u003eget_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below.\u003c/p\u003e","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","ContentHash":"1ce7920410c8b91d7f3fc228ad110a53186628beacffbe909d81f95db0ea95c2","Payload":{"description":["get_index_stats_hook: core extension hook declared in src/include/utils/selfuncs.h. The exact interface and call sites are recorded below."],"related":[{"label":"The Planner/Optimizer","url":"/docs/18/planner-optimizer.html"}],"sections":[{"paragraphs":["src/backend/utils/adt/selfuncs.c:5488","src/backend/utils/adt/selfuncs.c:6224","src/backend/utils/adt/selfuncs.c:8783"],"title":"Call sites"},{"code":"\t\t\t\t\t\t * a partial index.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * An index stats hook, however, must make its own\n\t\t\t\t\t\t * decisions about what to do with partial indexes.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t pos + 1, vardata))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * The hook took control of acquiring a stats\n\t\t\t\t\t\t\t * tuple.  If it did supply a tuple, it'd better\n\t\t\t\t\t\t\t * have supplied a freefunc.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:5482–5496"},{"code":"\t{\n\t\t/* Expression --- maybe there are stats for the index itself */\n\t\trelid = index-\u003eindexoid;\n\t\tcolnum = indexcol + 1;\n\n\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t(*get_index_stats_hook) (root, relid, colnum, vardata))\n\t\t{\n\t\t\t/*\n\t\t\t * The hook took control of acquiring a stats tuple.  If it did\n\t\t\t * supply a tuple, it'd better have supplied a freefunc.\n\t\t\t */\n\t\t\tif (HeapTupleIsValid(vardata-\u003estatsTuple) \u0026\u0026\n\t\t\t\t!vardata-\u003efreefunc)\n\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:6218–6232"},{"code":"\t\t\t */\n\n\t\t\t/* get the attnum from the 0-based index. */\n\t\t\tattnum = iclause-\u003eindexcol + 1;\n\n\t\t\tif (get_index_stats_hook \u0026\u0026\n\t\t\t\t(*get_index_stats_hook) (root, index-\u003eindexoid, attnum, \u0026vardata))\n\t\t\t{\n\t\t\t\t/*\n\t\t\t\t * The hook took control of acquiring a stats tuple.  If it\n\t\t\t\t * did supply a tuple, it'd better have supplied a freefunc.\n\t\t\t\t */\n\t\t\t\tif (HeapTupleIsValid(vardata.statsTuple) \u0026\u0026\n\t\t\t\t\t!vardata.freefunc)\n\t\t\t\t\telog(ERROR, \"no function provided to release variable stats with\");","paragraphs":[],"title":"Core call context: src/backend/utils/adt/selfuncs.c:8777–8791"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
