From: Jon Nelson <jnelson+pgsql@jamponi.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: bad plan: 8.4.8, hashagg, work_mem=1MB.
Date: Mon, 20 Jun 2011 14:31:05 -0500
Message-ID: <BANLkTike3P_0RSd--dZBcAZ+MKcy3ieDqQ@mail.gmail.com> (raw)
In-Reply-To: <6961.1308586099@sss.pgh.pa.us>
References: <BANLkTinbiNfgkXLf-1rDOGPdbXdS7tLt8w@mail.gmail.com>
<6961.1308586099@sss.pgh.pa.us>
On Mon, Jun 20, 2011 at 11:08 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Jon Nelson <jnelson+pgsql@jamponi.net> writes:
>> I ran a query recently where the result was very large. The outer-most
>> part of the query looked like this:
>
>> HashAggregate (cost=56886512.96..56886514.96 rows=200 width=30)
>> -> Result (cost=0.00..50842760.97 rows=2417500797 width=30)
>
>> The row count for 'Result' is in the right ballpark, but why does
>> HashAggregate think that it can turn 2 *billion* rows of strings (an
>> average of 30 bytes long) into only 200?
>
> 200 is the default assumption about number of groups when it's unable to
> make any statistics-based estimate. You haven't shown us any details so
> it's hard to say more than that.
What sorts of details would you like? The row count for the Result
line is approximately correct -- the stats for all tables are up to
date (the tables never change after import). statistics is set at 100
currently.
--
Jon
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: jnelson+pgsql@jamponi.net, tgl@sss.pgh.pa.us
Subject: Re: bad plan: 8.4.8, hashagg, work_mem=1MB.
In-Reply-To: <BANLkTike3P_0RSd--dZBcAZ+MKcy3ieDqQ@mail.gmail.com>
References: <BANLkTinbiNfgkXLf-1rDOGPdbXdS7tLt8w@mail.gmail.com> <6961.1308586099@sss.pgh.pa.us> <BANLkTike3P_0RSd--dZBcAZ+MKcy3ieDqQ@mail.gmail.com>
* 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