EXPLAIN and HashAggregate

From: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: EXPLAIN and HashAggregate
Date: 2006-03-04 19:37:01
Message-ID: 4409EC5D.7060307@kaltenbrunner.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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=55907600 width=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.85 rows=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 the
hashtable of the HashAggregate which is a bit unexpected for a plain
EXPLAIN.

Stefan

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-03-04 19:39:16 Re: problem with large maintenance_work_mem settings and
Previous Message Hannu Krosing 2006-03-04 19:29:44 Re: Constraint Exclusion and Partition Locking