Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feature: Use amflags to support Column-oriented scanning of custom ta… #407

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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.
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 << 1)

typedef enum RelOptKind
{
Expand Down
Loading