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 --- src/include/access/amapi.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/include/access/amapi.h') diff --git a/src/include/access/amapi.h b/src/include/access/amapi.h index f25c9d58a7d..c51de742ea0 100644 --- a/src/include/access/amapi.h +++ b/src/include/access/amapi.h @@ -140,6 +140,13 @@ typedef void (*amcostestimate_function) (struct PlannerInfo *root, double *indexCorrelation, double *indexPages); +/* estimate height of a tree-structured index + * + * XXX This just computes a value that is later used by amcostestimate. This + * API could be expanded to support passing more values if the need arises. + */ +typedef int (*amgettreeheight_function) (Relation rel); + /* parse index reloptions */ typedef bytea *(*amoptions_function) (Datum reloptions, bool validate); @@ -272,6 +279,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 */ -- cgit v1.2.3