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

Search Discussions

  • Tom Lane at Mar 4, 2006 at 7:50 pm

    Stefan Kaltenbrunner writes:
    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.
    Not really. EXPLAIN runs plan setup (ExecutorStart).

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedMar 4, '06 at 7:37p
activeMar 4, '06 at 7:50p
posts2
users2
websitepostgresql.org...
irc#postgresql

2 users in discussion

Stefan Kaltenbrunner: 1 post Tom Lane: 1 post

People

Translate

site design / logo © 2021 Grokbase