diff --git a/src/backend/columnar/cstore_customscan.c b/src/backend/columnar/cstore_customscan.c index e1dfee2ac..9a014123c 100644 --- a/src/backend/columnar/cstore_customscan.c +++ b/src/backend/columnar/cstore_customscan.c @@ -76,6 +76,7 @@ static void ColumnarScan_ExplainCustomScan(CustomScanState *node, List *ancestor static set_rel_pathlist_hook_type PreviousSetRelPathlistHook = NULL; static bool EnableColumnarCustomScan = true; +static bool EnableColumnarQualPushdown = true; const struct CustomPathMethods ColumnarScanPathMethods = { @@ -114,13 +115,23 @@ columnar_customscan_init() DefineCustomBoolVariable( "columnar.enable_custom_scan", gettext_noop("Enables the use of a custom scan to push projections and quals " - "into the storage layer"), + "into the storage layer."), NULL, &EnableColumnarCustomScan, true, PGC_USERSET, GUC_NO_SHOW_ALL, NULL, NULL, NULL); + DefineCustomBoolVariable( + "columnar.enable_qual_pushdown", + gettext_noop("Enables qual pushdown into columnar. This has no effect unless " + "columnar.enable_custom_scan is true."), + NULL, + &EnableColumnarQualPushdown, + true, + PGC_USERSET, + GUC_NO_SHOW_ALL, + NULL, NULL, NULL); } @@ -294,7 +305,10 @@ ColumnarScan_CreateCustomScanState(CustomScan *cscan) CustomScanState *cscanstate = &columnarScanState->custom_scanstate; cscanstate->methods = &ColumnarExecuteMethods; - columnarScanState->qual = cscan->scan.plan.qual; + if (EnableColumnarQualPushdown) + { + columnarScanState->qual = cscan->scan.plan.qual; + } return (Node *) cscanstate; } diff --git a/src/test/regress/input/am_chunk_filtering.source b/src/test/regress/input/am_chunk_filtering.source index 2b3e760a8..a0aa2ac91 100644 --- a/src/test/regress/input/am_chunk_filtering.source +++ b/src/test/regress/input/am_chunk_filtering.source @@ -76,6 +76,10 @@ CREATE TABLE simple_chunk_filtering(i int) USING COLUMNAR; INSERT INTO simple_chunk_filtering SELECT generate_series(0,234567); EXPLAIN (analyze on, costs off, timing off, summary off) SELECT * FROM simple_chunk_filtering WHERE i > 123456; +SET columnar.enable_qual_pushdown = false; +EXPLAIN (analyze on, costs off, timing off, summary off) + SELECT * FROM simple_chunk_filtering WHERE i > 123456; +SET columnar.enable_qual_pushdown TO DEFAULT; -- https://github.com/citusdata/citus/issues/4555 TRUNCATE simple_chunk_filtering; diff --git a/src/test/regress/output/am_chunk_filtering.source b/src/test/regress/output/am_chunk_filtering.source index 032be36b8..33a266fb0 100644 --- a/src/test/regress/output/am_chunk_filtering.source +++ b/src/test/regress/output/am_chunk_filtering.source @@ -130,6 +130,18 @@ EXPLAIN (analyze on, costs off, timing off, summary off) Columnar Chunks Removed by Filter: 12 (4 rows) +SET columnar.enable_qual_pushdown = false; +EXPLAIN (analyze on, costs off, timing off, summary off) + SELECT * FROM simple_chunk_filtering WHERE i > 123456; + QUERY PLAN +--------------------------------------------------------------------- + Custom Scan (ColumnarScan) on simple_chunk_filtering (actual rows=111111 loops=1) + Filter: (i > 123456) + Rows Removed by Filter: 123457 + Columnar Chunks Removed by Filter: 0 +(4 rows) + +SET columnar.enable_qual_pushdown TO DEFAULT; -- https://github.com/citusdata/citus/issues/4555 TRUNCATE simple_chunk_filtering; INSERT INTO simple_chunk_filtering SELECT generate_series(0,200000);