Skip to content

Commit 235aff9

Browse files
avaminglibaotingfang
authored andcommitted
Fix explain bad indent when showing operatorMem. (#288)
Word operatorMem is added by GPDB, it shows bad indent when explain. set gp_resqueue_print_operator_memory_limits=on; explain(costs off) select count(*) from test_hj_spill; QUERY PLAN ---------------------------------------------------------------------------- Finalize AggregateoperatorMem: 100 kB -> Gather Motion 3:1 (slice1; segments: 3)operatorMem: 100 kB -> Partial AggregateoperatorMem: 100 kB -> Seq Scan on test_hj_spilloperatorMem: 100 kB This is introduced by UPSTREAM commit 1001368 which tried to resolve explain indent of parallel query. Add indent manually for CBDB's additional operatorMem. Authored-by: Zhang Mingli avamingli@gmail.com
1 parent 23f0bd2 commit 235aff9

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/backend/commands/explain.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,9 +2083,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
20832083
}
20842084

20852085
if (ResManagerPrintOperatorMemoryLimits())
2086-
{
2087-
ExplainPropertyInteger("operatorMem", "kB", PlanStateOperatorMemKB(planstate), es);
2088-
}
2086+
appendStringInfo(es->str, " (operatorMem: "UINT64_FORMAT"kB)", PlanStateOperatorMemKB(planstate));
20892087
/*
20902088
* We have to forcibly clean up the instrumentation state because we
20912089
* haven't done ExecutorEnd yet. This is pretty grotty ...

src/test/regress/expected/workfile/hashjoin_spill.out

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ insert into test_hj_spill SELECT i,i,i%1000,i,i,i,i,i from
3939
(select count(*) as nsegments from gp_segment_configuration where role='p' and content >= 0) foo) bar;
4040
SET statement_mem=1024;
4141
set gp_resqueue_print_operator_memory_limits=on;
42+
explain(costs off) select count(i3), avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo;
43+
QUERY PLAN
44+
----------------------------------------------------------------------------------------------
45+
Finalize Aggregate (operatorMem: 100kB)
46+
-> Gather Motion 3:1 (slice1; segments: 3) (operatorMem: 100kB)
47+
-> Partial Aggregate (operatorMem: 100kB)
48+
-> Hash Left Join (operatorMem: 100kB)
49+
Hash Cond: (t2.i2 = t1.i1)
50+
-> Redistribute Motion 3:3 (slice2; segments: 3) (operatorMem: 100kB)
51+
Hash Key: t2.i2
52+
-> Seq Scan on test_hj_spill t2 (operatorMem: 100kB)
53+
-> Hash (operatorMem: 624kB)
54+
-> Seq Scan on test_hj_spill t1 (operatorMem: 100kB)
55+
Optimizer: Postgres query optimizer
56+
(11 rows)
57+
4258
set gp_workfile_compression = on;
4359
select count(i3), avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo;
4460
count | avg

src/test/regress/sql/workfile/hashjoin_spill.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ insert into test_hj_spill SELECT i,i,i%1000,i,i,i,i,i from
4242
(select count(*) as nsegments from gp_segment_configuration where role='p' and content >= 0) foo) bar;
4343
SET statement_mem=1024;
4444
set gp_resqueue_print_operator_memory_limits=on;
45+
explain(costs off) select count(i3), avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo;
4546

4647
set gp_workfile_compression = on;
4748
select count(i3), avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo;

0 commit comments

Comments
 (0)