-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support vectorized aggregation on Hypercore TAM
Add support for running VectorAgg on top of scans on Hypercore TAM. Currently, only ColumnarScan can run below VectorAgg when Hypercore TAM is used. In theory, a SeqScan or IndexScan reading from Hypercore TAM should also work because they would produce Arrow slots. However, only ColumnarScan performs vectorized filtering, which is currently assumed to happen before the VectorAgg node. In ColumnarScan, it is necessary to turn off projection when VectorAgg is used. Otherwise, it would project the arrow slot into a virtual slot, thus losing the vector data. Ideally, a projection should never be planned to begin with, but this isn't possible since VectorAgg modifies existing non-vectorized Agg plans that already includes projections.
- Loading branch information
Showing
29 changed files
with
1,247 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implements: #7655 Support vectorized aggregation on Hypercore TAM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* This file and its contents are licensed under the Timescale License. | ||
* Please see the included NOTICE for copyright information and | ||
* LICENSE-TIMESCALE for a copy of the license. | ||
*/ | ||
#include <postgres.h> | ||
#include <access/attnum.h> | ||
#include <nodes/parsenodes.h> | ||
#include <parser/parsetree.h> | ||
|
||
#include "hypercore/hypercore_handler.h" | ||
#include "nodes/decompress_chunk/vector_quals.h" | ||
#include "plan.h" | ||
|
||
bool | ||
vectoragg_plan_tam(Plan *childplan, const List *rtable, VectorQualInfo *vqi) | ||
{ | ||
const CustomScan *customscan = castNode(CustomScan, childplan); | ||
RangeTblEntry *rte = rt_fetch(customscan->scan.scanrelid, rtable); | ||
Relation rel = table_open(rte->relid, AccessShareLock); | ||
const HypercoreInfo *hinfo = RelationGetHypercoreInfo(rel); | ||
|
||
*vqi = (VectorQualInfo){ | ||
.rti = customscan->scan.scanrelid, | ||
.vector_attrs = (bool *) palloc0(sizeof(bool) * (hinfo->num_columns + 1)), | ||
.segmentby_attrs = (bool *) palloc0(sizeof(bool) * (hinfo->num_columns + 1)), | ||
/* | ||
* Hypercore TAM and ColumnarScan do not yet support specific ordering | ||
* (via pathkeys) so vector data will always be as read. | ||
*/ | ||
.reverse = false, | ||
}; | ||
|
||
for (int i = 0; i < hinfo->num_columns; i++) | ||
{ | ||
AttrNumber attno = AttrOffsetGetAttrNumber(i); | ||
|
||
if (!hinfo->columns[i].is_dropped) | ||
{ | ||
/* | ||
* Hypercore TAM only supports bulk decompression, so all columns | ||
* are vectorizable, including segmentby columns. | ||
*/ | ||
vqi->vector_attrs[attno] = true; | ||
vqi->segmentby_attrs[attno] = hinfo->columns[i].is_segmentby; | ||
} | ||
} | ||
|
||
table_close(rel, NoLock); | ||
|
||
return true; | ||
} |
Oops, something went wrong.