Skip to content

Commit 259c405

Browse files
POC for rewriting queries with Caggs, add early validations
1 parent 9741d94 commit 259c405

24 files changed

+2578
-793
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
@@ -151,6 +151,8 @@ TSDLLEXPORT bool ts_guc_enable_delete_after_compression = false;
151151
TSDLLEXPORT bool ts_guc_enable_merge_on_cagg_refresh = false;
152152

153153
bool ts_guc_enable_partitioned_hypertables = false;
154+
TSDLLEXPORT bool ts_guc_enable_cagg_rewrites = false;
155+
TSDLLEXPORT bool ts_guc_cagg_rewrites_debug_info = false;
154156

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

797+
DefineCustomBoolVariable(MAKE_EXTOPTION("enable_cagg_rewrites"),
798+
"Enable rewriting queries with Caggs",
799+
"Enable rewriting queries with eligible continuous aggregates",
800+
&ts_guc_enable_cagg_rewrites,
801+
false,
802+
PGC_USERSET,
803+
0,
804+
NULL,
805+
NULL,
806+
NULL);
807+
808+
DefineCustomBoolVariable(MAKE_EXTOPTION("cagg_rewrites_debug_info"),
809+
"Print debug info about whether queries can be rewritten with Caggs",
810+
"Print debug info about whether queries can be rewritten with Caggs",
811+
&ts_guc_cagg_rewrites_debug_info,
812+
false,
813+
PGC_USERSET,
814+
0,
815+
NULL,
816+
NULL,
817+
NULL);
818+
795819
DefineCustomBoolVariable(MAKE_EXTOPTION("enable_compression_wal_markers"),
796820
"Enable WAL markers for compression ops",
797821
"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
@@ -81,6 +81,9 @@ extern TSDLLEXPORT bool ts_guc_enable_multikey_skip_scan;
8181
extern TSDLLEXPORT double ts_guc_skip_scan_run_cost_multiplier;
8282
extern TSDLLEXPORT bool ts_guc_debug_skip_scan_info;
8383

84+
extern TSDLLEXPORT bool ts_guc_enable_cagg_rewrites;
85+
extern TSDLLEXPORT bool ts_guc_cagg_rewrites_debug_info;
86+
8487
/* Only settable in debug mode for testing */
8588
extern TSDLLEXPORT bool ts_guc_enable_null_compression;
8689
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)