Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix explain bad indent when showing operatorMem. #292

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/backend/commands/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down
19 changes: 19 additions & 0 deletions src/test/regress/expected/gp_aggregates_costs.out
Original file line number Diff line number Diff line change
Expand Up @@ -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;
19 changes: 19 additions & 0 deletions src/test/regress/expected/gp_aggregates_costs_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -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;
12 changes: 12 additions & 0 deletions src/test/regress/sql/gp_aggregates_costs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;