Skip to content

Commit db51394

Browse files
POC for rewriting queries with Caggs, add early validations
1 parent 3d0afb0 commit db51394

24 files changed

+2999
-794
lines changed

.unreleased/pr_8967

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implements: #8967 Rewriting queries with continuous aggregates exactly matching query aggregation

src/guc.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ TSDLLEXPORT bool ts_guc_enable_delete_after_compression = false;
152152
TSDLLEXPORT bool ts_guc_enable_merge_on_cagg_refresh = false;
153153

154154
bool ts_guc_enable_partitioned_hypertables = false;
155+
TSDLLEXPORT bool ts_guc_enable_cagg_rewrites = false;
156+
TSDLLEXPORT bool ts_guc_cagg_rewrites_debug_info = false;
155157

156158
/* default value of ts_guc_max_open_chunks_per_insert and
157159
* ts_guc_max_cached_chunks_per_hypertable will be set as their respective boot-value when the
@@ -793,6 +795,28 @@ _guc_init(void)
793795
NULL,
794796
NULL);
795797

798+
DefineCustomBoolVariable(MAKE_EXTOPTION("enable_cagg_rewrites"),
799+
"Enable rewriting queries with Caggs",
800+
"Enable rewriting queries with eligible continuous aggregates",
801+
&ts_guc_enable_cagg_rewrites,
802+
false,
803+
PGC_USERSET,
804+
0,
805+
NULL,
806+
NULL,
807+
NULL);
808+
809+
DefineCustomBoolVariable(MAKE_EXTOPTION("cagg_rewrites_debug_info"),
810+
"Print debug info about whether queries can be rewritten with Caggs",
811+
"Print debug info about whether queries can be rewritten with Caggs",
812+
&ts_guc_cagg_rewrites_debug_info,
813+
false,
814+
PGC_USERSET,
815+
0,
816+
NULL,
817+
NULL,
818+
NULL);
819+
796820
DefineCustomBoolVariable(MAKE_EXTOPTION("enable_compression_wal_markers"),
797821
"Enable WAL markers for compression ops",
798822
"Enable the generation of markers in the WAL stream which mark the "

src/guc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ extern TSDLLEXPORT bool ts_guc_enable_multikey_skip_scan;
8282
extern TSDLLEXPORT double ts_guc_skip_scan_run_cost_multiplier;
8383
extern TSDLLEXPORT bool ts_guc_debug_skip_scan_info;
8484

85+
extern TSDLLEXPORT bool ts_guc_enable_cagg_rewrites;
86+
extern TSDLLEXPORT bool ts_guc_cagg_rewrites_debug_info;
87+
8588
/* Only settable in debug mode for testing */
8689
extern TSDLLEXPORT bool ts_guc_enable_null_compression;
8790
extern TSDLLEXPORT bool ts_guc_enable_compression_ratio_warnings;

src/planner/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set(SOURCES
44
${CMAKE_CURRENT_SOURCE_DIR}/agg_bookend.c
55
${CMAKE_CURRENT_SOURCE_DIR}/constify_now.c
66
${CMAKE_CURRENT_SOURCE_DIR}/constraint_cleanup.c
7+
${CMAKE_CURRENT_SOURCE_DIR}/continuous_aggs_common.c
8+
${CMAKE_CURRENT_SOURCE_DIR}/continuous_agg_rewrites.c
79
${CMAKE_CURRENT_SOURCE_DIR}/expand_hypertable.c
810
${CMAKE_CURRENT_SOURCE_DIR}/partialize.c
911
${CMAKE_CURRENT_SOURCE_DIR}/space_constraint.c)

0 commit comments

Comments
 (0)