summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util/plancat.c
diff options
context:
space:
mode:
authorPeter Eisentraut2024-09-10 07:51:55 +0000
committerPeter Eisentraut2024-09-10 08:03:23 +0000
commit56fead44dcc70df9f9188fee08e5aefe3da43ccc (patch)
treee7b2c776e4d5f2727403d19c16066d6ffb28a741 /src/backend/optimizer/util/plancat.c
parentf5050f795aea67dfc40bbc429c8934e9439e22e7 (diff)
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 <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
Diffstat (limited to 'src/backend/optimizer/util/plancat.c')
-rw-r--r--src/backend/optimizer/util/plancat.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 78a3cfafde4..82f031f4cfe 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -241,7 +241,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
Oid indexoid = lfirst_oid(l);
Relation indexRelation;
Form_pg_index index;
- IndexAmRoutine *amroutine;
+ IndexAmRoutine *amroutine = NULL;
IndexOptInfo *info;
int ncolumns,
nkeycolumns;
@@ -485,13 +485,12 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
info->tuples = rel->tuples;
}
- if (info->relam == BTREE_AM_OID)
+ /*
+ * Get tree height while we have the index open
+ */
+ if (amroutine->amgettreeheight)
{
- /*
- * For btrees, get tree height while we have the index
- * open
- */
- info->tree_height = _bt_getrootheight(indexRelation);
+ info->tree_height = amroutine->amgettreeheight(indexRelation);
}
else
{