From 56fead44dcc70df9f9188fee08e5aefe3da43ccc Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 10 Sep 2024 09:51:55 +0200 Subject: Add amgettreeheight index AM API routine The only current implementation is for btree where it calls _bt_getrootheight(). Other index types can now also use this to pass information to their amcostestimate routine. Previously, btree was hardcoded and other index types could not hook into the optimizer at this point. Author: Mark Dilger Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com --- doc/src/sgml/indexam.sgml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index e3c1539a1e3..dc7d14b60dd 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -146,6 +146,7 @@ typedef struct IndexAmRoutine amvacuumcleanup_function amvacuumcleanup; amcanreturn_function amcanreturn; /* can be NULL */ amcostestimate_function amcostestimate; + amgettreeheight_function amgettreeheight; /* can be NULL */ amoptions_function amoptions; amproperty_function amproperty; /* can be NULL */ ambuildphasename_function ambuildphasename; /* can be NULL */ @@ -480,6 +481,21 @@ amcostestimate (PlannerInfo *root, +int +amgettreeheight (Relation rel); + + Compute the height of a tree-shaped index. This information is supplied to + the amcostestimate function in + path->indexinfo->tree_height and can be used to support + the cost estimation. The result is not used anywhere else, so this + function can actually be used to compute any kind of data (that fits into + an integer) about the index that the cost estimation function might want to + know. If the computation is expensive, it could be useful to cache the + result as part of RelationData.rd_amcache. + + + + bytea * amoptions (ArrayType *reloptions, bool validate); -- cgit v1.2.3