Re: queries with DISTINCT / GROUP BY giving different plans

From: Tomas Vondra <tv(at)fuzzy(dot)cz>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: queries with DISTINCT / GROUP BY giving different plans
Date: 2013-08-20 22:21:24
Message-ID: 5213EBE4.5030302@fuzzy.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 20.8.2013 23:02, Tom Lane wrote:
> Tomas Vondra <tv(at)fuzzy(dot)cz> writes:
>
>> Anyway, I still don't understand why the same logic around
>> hash_agg_entry_size should not apply to choose_hashed_grouping as
>> well? Well, it would make it slower in this particular corner case,
>> but wouldn't it be more correct?

Meh, I meant it the other way around - applying the hashentrysize logic
from hashed_grouping to hashed_distinct. So that both use 56B.

> choose_hashed_grouping has it right, or at least more nearly right.
> choose_hashed_distinct is simply failing to account for space that
> will in fact be consumed. Not fixing that is not a good way to deal
> with inaccurate number-of-groups estimates; if that estimate is low
> rather than high, the consequences will be a lot worse than they are
> here.

Not quite sure how to parse this (not a native speaker here, sorry).
Does that mean we want to keep it as it is now (because fixing it would
cause even worse errors with low estimates)? Or do we want to fix
hashed_distinct so that it behaves like hashed_grouping?

Tomas

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2013-08-20 23:32:09 Re: queries with DISTINCT / GROUP BY giving different plans
Previous Message Tom Lane 2013-08-20 21:02:09 Re: queries with DISTINCT / GROUP BY giving different plans