diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 1037ada162d..797c38e6cf5 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -813,7 +813,14 @@ get_index_paths(PlannerInfo *root, RelOptInfo *rel, */ if (index->amhasgettuple) { - if (!AMHandlerIsAO(rel->amhandler) || + /* + * PAX shares AO's planner concern: random TID fetch + * re-decompresses whole stripes and bypasses the buffer pool. + * Treat it as AO-like so only Bitmap paths survive add_path + * here. + */ + if ((!AMHandlerIsAO(rel->amhandler) && + rel->relam != PAX_AM_OID) || index->amcostestimate == bmcostestimate) add_path(rel, (Path *) ipath, root); else if (gp_enable_ao_indexscan && !IsA(ipath, IndexOnlyScan)) diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index f1d08a4d128..330a2539a76 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -158,6 +158,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, */ rel->cdbpolicy = RelationGetPartitioningKey(relation); rel->amhandler = relation->rd_amhandler; + rel->relam = relation->rd_rel->relam; /* * Estimate relation size --- unless it's an inheritance parent, in which diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index 3cd21590ac9..2c6a2b4bdbe 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -913,6 +913,7 @@ typedef struct RelOptInfo double tuples; struct GpPolicy *cdbpolicy; /* distribution of stored tuples */ Oid amhandler; /* from relcache entry */ + Oid relam; /* pg_class.relam (table AM oid) */ double allvisfrac; Bitmapset *eclass_indexes; /* Indexes in PlannerInfo's eq_classes list of * ECs that mention this rel */