diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c index 1eee611e022..6ff94ac7d76 100644 --- a/src/backend/access/table/tableam.c +++ b/src/backend/access/table/tableam.c @@ -284,11 +284,11 @@ table_index_fetch_tuple_check(Relation rel, bool found; /* - * Optimized path for AO/CO relations as the aforementioned per-tuple - * overhead is significant for AO/CO relations. For details, please refer to + * Optimized path for non-heap relations as the aforementioned per-tuple + * overhead is significant for non-heap relations. For details, please refer to * table_index_unique_check(). */ - if (RelationIsAppendOptimized(rel)) + if (rel->rd_tableam->index_unique_check) return table_index_unique_check(rel, tid, snapshot, all_dead); slot = table_slot_create(rel, NULL); diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 3144d37b186..15fa3775bdf 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -73,6 +73,16 @@ static inline void BitmapPrefetch(BitmapHeapScanState *node, static bool BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate); static void ExecEagerFreeBitmapHeapScan(BitmapHeapScanState *node); +/* + * Other non-heap table access method may use bitmap scan, + * the prefetch will not work for them if they have + * non-standard page-based storage. + */ +static inline bool +RelationSupportPrefetch(Relation rel) +{ + return RelationIsHeap(rel); +} /* * Free the state relevant to bitmaps @@ -325,7 +335,8 @@ BitmapHeapNext(BitmapHeapScanState *node) * XXX: It's a layering violation that we do these checks above * tableam, they should probably moved below it at some point. */ - BitmapPrefetch(node, scan); + if (RelationSupportPrefetch(scan->rs_rd)) + BitmapPrefetch(node, scan); if (node->return_empty_tuples > 0) {