EXPLAIN and HashAggregate - Mailing list pgsql-hackers

From Stefan Kaltenbrunner
Subject EXPLAIN and HashAggregate
Date
Msg-id 4409EC5D.7060307@kaltenbrunner.cc
Whole thread Raw
Responses Re: EXPLAIN and HashAggregate
List pgsql-hackers
While playing around with large work_mem(or in that case a bit insane)
and maintenance_work_mem settings I noticed that EXPLAIN behaves quite
weird:

foo=# set work_mem to 200000;
SET
Time: 0.187 ms
foo=# explain select count(*) from testtable2 group by a;                                   QUERY PLAN


--------------------------------------------------------------------------------
---GroupAggregate  (cost=8845616.04..9731787.89 rows=37349188 width=4)  ->  Sort  (cost=8845616.04..8985385.04
rows=55907600width=4)        Sort Key: a        ->  Seq Scan on testtable2  (cost=0.00..1088488.00
 
rows=55907600 width=
4)
(4 rows)

Time: 0.364 ms
foo=# set work_mem to 2500000;
SET
Time: 0.195 ms
foo=# explain select count(*) from testtable2 group by a;                                QUERY PLAN

-----------------------------------------------------------------------------HashAggregate
(cost=1368026.00..1834890.85rows=37349188 width=4)  ->  Seq Scan on testtable2  (cost=0.00..1088488.00 rows=55907600
width=4)
(2 rows)

Time: 615.108 ms


it looks like that postgresql is actually allocating the memory for thehashtable of the HashAggregate which is a bit
unexpectedfor a plain
 
EXPLAIN.


Stefan


pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Constraint Exclusion and Partition Locking
Next
From: Tom Lane
Date:
Subject: Re: problem with large maintenance_work_mem settings and