Skip to content

Commit

Permalink
Merge remote-tracking branch 'hydra/custom-index-scan' into index-scan
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaruza committed Nov 29, 2023
2 parents 97cbedb + 7905d25 commit e89efba
Show file tree
Hide file tree
Showing 13 changed files with 1,264 additions and 18 deletions.
12 changes: 12 additions & 0 deletions columnar/src/backend/columnar/columnar.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ bool columnar_enable_vectorization = true;
bool columnar_enable_dml = true;
bool columnar_enable_page_cache = true;
int columnar_page_cache_size = 200U;
bool columnar_index_scan = false;

static const struct config_enum_entry columnar_compression_options[] =
{
Expand Down Expand Up @@ -195,6 +196,17 @@ columnar_guc_init()
NULL,
NULL,
NULL);

DefineCustomBoolVariable("columnar.enable_columnar_index_scan",
gettext_noop("Enables custom columnar index scan"),
NULL,
&columnar_index_scan,
false,
PGC_USERSET,
GUC_NO_SHOW_ALL,
NULL,
NULL,
NULL);
}


Expand Down
13 changes: 8 additions & 5 deletions columnar/src/backend/columnar/columnar_customscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ static List * set_deparse_context_planstate(List *dpcontext, Node *node,

/* other helpers */
static List * ColumnarVarNeeded(ColumnarScanState *columnarScanState);
static Bitmapset * ColumnarAttrNeeded(ScanState *ss, List *customList);
static bool IsCreateTableAs(const char *query);

/* saved hook value in case of unload */
Expand Down Expand Up @@ -608,9 +607,13 @@ CostColumnarIndexPath(PlannerInfo *root, RelOptInfo *rel, Oid relationId,
* instead of overwriting total cost, we "add" ours to the cost estimated
* by indexAM since we should consider index traversal related costs too.
*/
Cost columnarIndexScanCost = ColumnarIndexScanAdditionalCost(root, rel, relationId,
indexPath);
indexPath->path.total_cost += columnarIndexScanCost;

if (!columnar_index_scan)
{
Cost columnarIndexScanCost = ColumnarIndexScanAdditionalCost(root, rel, relationId,
indexPath);
indexPath->path.total_cost += columnarIndexScanCost;
}

ereport(DEBUG4, (errmsg("columnar table index scan costs re-estimated "
"by columnarAM (including indexAM costs): "
Expand Down Expand Up @@ -1986,7 +1989,7 @@ ColumnarScan_BeginCustomScan(CustomScanState *cscanstate, EState *estate, int ef
* Throws an error if finds a Var referencing to an attribute not supported
* by ColumnarScan.
*/
static Bitmapset *
Bitmapset *
ColumnarAttrNeeded(ScanState *ss, List *customList)
{
TupleTableSlot *slot = ss->ss_ScanTupleSlot;
Expand Down
Loading

0 comments on commit e89efba

Please sign in to comment.