diff --git a/src/backend/access/aocs/aocsam_handler.c b/src/backend/access/aocs/aocsam_handler.c index 883219e69b1..b5077c70466 100644 --- a/src/backend/access/aocs/aocsam_handler.c +++ b/src/backend/access/aocs/aocsam_handler.c @@ -760,7 +760,7 @@ aoco_getnextslot(TableScanDesc scan, ScanDirection direction, TupleTableSlot *sl static uint32 aoco_scan_flags(Relation rel) { - return 0; + return SCAN_SUPPORT_COLUMN_ORIENTED_SCAN; } static Size diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index ff6f05919b4..05131746da2 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -974,7 +974,7 @@ use_physical_tlist(PlannerInfo *root, Path *path, int flags) * Using physical target list with column store will result in scanning all * column files, which will cause a significant performance degradation. */ - if (AMHandlerIsAoCols(rel->amhandler)) + if (rel->amflags & AMFLAG_HAS_COLUMN_ORIENTED_SCAN) return false; /* diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 832635cb981..3e1f81a69e3 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -491,6 +491,12 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, relation->rd_tableam->scan_getnextslot_tidrange != NULL) rel->amflags |= AMFLAG_HAS_TID_RANGE; + /* Collect info about relation's store information, if it support column-oriented scan */ + if (relation->rd_tableam && relation->rd_tableam->scan_flags && + (relation->rd_tableam->scan_flags(relation) & SCAN_SUPPORT_COLUMN_ORIENTED_SCAN)) { + rel->amflags |= AMFLAG_HAS_COLUMN_ORIENTED_SCAN; + } + /* * Collect info about relation's partitioning scheme, if any. Only * inheritance parents may be partitioned. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index f272625eb36..f5469785c07 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -41,6 +41,18 @@ struct TBMIterateResult; struct VacuumParams; struct ValidateIndexState; +/** + * Flags represented the supported features of scan. + * + * The first 8 bits are reserved for kernel expansion of some attributes, + * and the remaining 24 bits are reserved for custom tableam. + * + * If you add a new flag, make sure the flag's bit is consecutive with + * the previous one. + * +*/ +#define SCAN_SUPPORT_COLUMN_ORIENTED_SCAN (1 << 0) /* support column-oriented scanning*/ + /* * Bitmask values for the flags argument to the scan_begin callback. */ diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index a701bea75af..695b4dbc5e3 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -823,6 +823,8 @@ static inline void planner_subplan_put_plan(struct PlannerInfo *root, SubPlan *s /* Bitmask of flags supported by table AMs */ #define AMFLAG_HAS_TID_RANGE (1 << 0) +/* Column-oriented scanning of flags supported by table AMs */ +#define AMFLAG_HAS_COLUMN_ORIENTED_SCAN (1 << 1) typedef enum RelOptKind {