Skip to content

Commit

Permalink
feature: Use amflags to support Column-oriented scanning of custom ta…
Browse files Browse the repository at this point in the history
…bleam

For custom tableam, maybe it support column-oriented scanning, the postgres
planner can no longer use whether am_handler is aocs handler to decide
whether only to add the columns required by the operator to the targetlist,
but use amflags to determine

If table am supports column-oriented scanning, the flags returned by set_flags
will set the SCAN_SUPPORT_COLUMN_ORIENTED_SCAN bit.
  • Loading branch information
GongXun committed Apr 11, 2024
1 parent be6897c commit c9d0a10
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/access/aocs/aocsam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/backend/optimizer/plan/createplan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down
6 changes: 6 additions & 0 deletions src/backend/optimizer/util/plancat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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's column store */
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.
Expand Down
12 changes: 12 additions & 0 deletions src/include/access/tableam.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/include/nodes/pathnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 << 0)

typedef enum RelOptKind
{
Expand Down

0 comments on commit c9d0a10

Please sign in to comment.