From: Tom Lane <tgl@sss.pgh.pa.us>
To: Erik Norvelle <signups@norvelle.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow performance with Group By
Date: Mon, 08 Nov 2004 19:56:04 -0500
Message-ID: <12781.1099961764@sss.pgh.pa.us> (raw)
In-Reply-To: <B14B76F4-31E3-11D9-8120-000A9583BF06@norvelle.org>
References: <B14B76F4-31E3-11D9-8120-000A9583BF06@norvelle.org>
Erik Norvelle <signups@norvelle.org> writes:
>>> it=> explain select codelemm, sectref, count(codelemm) from indethom
> group by codelemm, sectref;
>>> QUERY PLAN
>>> -----------------------------------------------------------------------
> ---------
>>> GroupAggregate (cost=2339900.60..2444149.44 rows=1790528 width=13)
>>> -> Sort (cost=2339900.60..2364843.73 rows=9977252 width=13)
>>> Sort Key: codelemm, sectref
>>> -> Seq Scan on indethom (cost=0.00..455264.52 rows=9977252
> width=13)
Actually the painful part of that is the sort. If you bump up sort_mem
enough it will eventually switch over to a HashAggregate with no sort,
which may be a better plan if there's not too many groups (is the
estimate of 1.79 million on the mark at all??)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, signups@norvelle.org
Subject: Re: Slow performance with Group By
In-Reply-To: <12781.1099961764@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox