diff options
author | Peter Eisentraut | 2024-09-10 07:51:55 +0000 |
---|---|---|
committer | Peter Eisentraut | 2024-09-10 08:03:23 +0000 |
commit | 56fead44dcc70df9f9188fee08e5aefe3da43ccc (patch) | |
tree | e7b2c776e4d5f2727403d19c16066d6ffb28a741 /src/backend/optimizer | |
parent | f5050f795aea67dfc40bbc429c8934e9439e22e7 (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 <mark.dilger@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r-- | src/backend/optimizer/util/plancat.c | 13 |
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 { |