Skip to content

Commit

Permalink
Support for partial aggregations at chunk level
Browse files Browse the repository at this point in the history
This patch adds support for partial aggregations at the chunk level.
The aggregation is replanned in the create_upper_paths_hook of
PostgreSQL. The AggPath is split up into multiple
AGGSPLIT_INITIAL_SERIAL operations (one on top of each chunk), which
create partials, and one AGGSPLIT_FINAL_DESERIAL operation, which
finalizes the aggregation.
  • Loading branch information
jnidzwetzki committed Aug 31, 2023
1 parent c6a9308 commit 7c843e1
Show file tree
Hide file tree
Showing 46 changed files with 4,754 additions and 1,910 deletions.
1 change: 1 addition & 0 deletions .unreleased/feature_5596
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implements: #5596 Support for partial aggregations at chunk level
26 changes: 26 additions & 0 deletions src/guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ TSDLLEXPORT bool ts_guc_enable_decompression_sorted_merge = true;
bool ts_guc_enable_per_data_node_queries = true;
bool ts_guc_enable_parameterized_data_node_scan = true;
bool ts_guc_enable_async_append = true;
bool ts_guc_enable_partitionwise_plain_sorted_aggregation = true;
bool ts_guc_enable_partitionwise_hashed_aggregation = true;
TSDLLEXPORT bool ts_guc_enable_compression_indexscan = true;
TSDLLEXPORT bool ts_guc_enable_bulk_decompression = true;
TSDLLEXPORT bool ts_guc_enable_skip_scan = true;
Expand Down Expand Up @@ -546,6 +548,30 @@ _guc_init(void)
NULL,
NULL);

DefineCustomBoolVariable("timescaledb.partitionwise_plain_sorted_aggregation",
"Enable partition-wise plain/sorted aggregation per chunk",
"Enable the partition-wise aggregation pushdown to the"
"chunk level",
&ts_guc_enable_partitionwise_plain_sorted_aggregation,
true,
PGC_USERSET,
0,
NULL,
NULL,
NULL);

DefineCustomBoolVariable("timescaledb.partitionwise_hashed_aggregation",
"Enable partition-wise hashed aggregation per chunk",
"Enable the partition-wise aggregation pushdown to the"
"chunk level",
&ts_guc_enable_partitionwise_hashed_aggregation,
true,
PGC_USERSET,
0,
NULL,
NULL,
NULL);

DefineCustomBoolVariable("timescaledb.enable_remote_explain",
"Show explain from remote nodes when using VERBOSE flag",
"Enable getting and showing EXPLAIN output from remote nodes",
Expand Down
2 changes: 2 additions & 0 deletions src/guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ extern TSDLLEXPORT bool ts_guc_enable_per_data_node_queries;
extern TSDLLEXPORT bool ts_guc_enable_parameterized_data_node_scan;
extern TSDLLEXPORT bool ts_guc_enable_async_append;
extern TSDLLEXPORT bool ts_guc_enable_skip_scan;
extern TSDLLEXPORT bool ts_guc_enable_partitionwise_plain_sorted_aggregation;
extern TSDLLEXPORT bool ts_guc_enable_partitionwise_hashed_aggregation;
extern bool ts_guc_restoring;
extern int ts_guc_max_open_chunks_per_insert;
extern int ts_guc_max_cached_chunks_per_hypertable;
Expand Down
1 change: 1 addition & 0 deletions src/nodes/chunk_append/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ ts_chunk_append_get_scan_plan(Plan *plan)
return NULL;
break;
case T_MergeAppend:
case T_Agg:
return NULL;
break;
default:
Expand Down
Loading

0 comments on commit 7c843e1

Please sign in to comment.