diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 14f1bf596bc..d44a70b04e9 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -2083,9 +2083,7 @@ ExplainNode(PlanState *planstate, List *ancestors, } if (ResManagerPrintOperatorMemoryLimits()) - { - ExplainPropertyInteger("operatorMem", "kB", PlanStateOperatorMemKB(planstate), es); - } + appendStringInfo(es->str, " (operatorMem: "UINT64_FORMAT"kB)", PlanStateOperatorMemKB(planstate)); /* * We have to forcibly clean up the instrumentation state because we * haven't done ExecutorEnd yet. This is pretty grotty ... diff --git a/src/test/regress/expected/gp_aggregates_costs.out b/src/test/regress/expected/gp_aggregates_costs.out index 40450d42192..69b1b15eb9d 100644 --- a/src/test/regress/expected/gp_aggregates_costs.out +++ b/src/test/regress/expected/gp_aggregates_costs.out @@ -111,3 +111,22 @@ explain (costs off) select b, sum(a) from t_planner_force_multi_stage group by b reset gp_eager_two_phase_agg; drop table t_planner_force_multi_stage; +-- test operatorMem +begin; +create table test_operator_mem (i int, j int) distributed by (i); +insert into test_operator_mem select i, i+1 from generate_series(1, 100)i; +analyze test_operator_mem; +set local statement_mem=1024; +set local gp_resqueue_print_operator_memory_limits=on; +explain(costs off) +select count(*) from test_operator_mem; + QUERY PLAN +----------------------------------------------------------------------- + Finalize Aggregate (operatorMem: 100kB) + -> Gather Motion 3:1 (slice1; segments: 3) (operatorMem: 100kB) + -> Partial Aggregate (operatorMem: 100kB) + -> Seq Scan on test_operator_mem (operatorMem: 100kB) + Optimizer: Postgres query optimizer +(5 rows) + +abort; diff --git a/src/test/regress/expected/gp_aggregates_costs_optimizer.out b/src/test/regress/expected/gp_aggregates_costs_optimizer.out index 6e01a735838..96f319484f3 100644 --- a/src/test/regress/expected/gp_aggregates_costs_optimizer.out +++ b/src/test/regress/expected/gp_aggregates_costs_optimizer.out @@ -111,3 +111,22 @@ explain (costs off) select b, sum(a) from t_planner_force_multi_stage group by b reset gp_eager_two_phase_agg; drop table t_planner_force_multi_stage; +-- test operatorMem +begin; +create table test_operator_mem (i int, j int) distributed by (i); +insert into test_operator_mem select i, i+1 from generate_series(1, 100)i; +analyze test_operator_mem; +set local statement_mem=1024; +set local gp_resqueue_print_operator_memory_limits=on; +explain(costs off) +select count(*) from test_operator_mem; + QUERY PLAN +----------------------------------------------------------------------- + Finalize Aggregate (operatorMem: 100kB) + -> Gather Motion 3:1 (slice1; segments: 3) (operatorMem: 100kB) + -> Partial Aggregate (operatorMem: 100kB) + -> Seq Scan on test_operator_mem (operatorMem: 100kB) + Optimizer: Pivotal Optimizer (GPORCA) +(5 rows) + +abort; diff --git a/src/test/regress/sql/gp_aggregates_costs.sql b/src/test/regress/sql/gp_aggregates_costs.sql index 7f77647246d..c1337de6083 100644 --- a/src/test/regress/sql/gp_aggregates_costs.sql +++ b/src/test/regress/sql/gp_aggregates_costs.sql @@ -47,3 +47,15 @@ set gp_eager_two_phase_agg = on; explain (costs off) select b, sum(a) from t_planner_force_multi_stage group by b; reset gp_eager_two_phase_agg; drop table t_planner_force_multi_stage; + +-- test operatorMem +begin; +create table test_operator_mem (i int, j int) distributed by (i); +insert into test_operator_mem select i, i+1 from generate_series(1, 100)i; +analyze test_operator_mem; +set local statement_mem=1024; +set local gp_resqueue_print_operator_memory_limits=on; +explain(costs off) +select count(*) from test_operator_mem; + +abort;