Re: Extremely slow HashAggregate in simple UNION query

From: Andres Freund <andres(at)anarazel(dot)de>
To: Felix Geisendörfer <felix(at)felixge(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Extremely slow HashAggregate in simple UNION query
Date: 2019-08-20 18:27:17
Message-ID: 20190820182717.ts3zhnjhuzjcbds3@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

On 2019-08-20 19:55:56 +0200, Felix Geisendörfer wrote:
> > On 20. Aug 2019, at 19:32, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > FWIW, that's not a mis-estimate I'm getting on master ;). Obviously
> > that doesn't actually address your concern...
>
> I suppose this is thanks to the new optimizer support functions
> mentioned by Michael and Pavel?

Right.

> > Under-sizing the hashtable just out of caution will have add overhead to
> > a lot more common cases. That requires copying data around during
> > growth, which is far far from free. Or you can use hashtables that don't
> > need to copy, but they're also considerably slower in the more common
> > cases.
>
> How does PostgreSQL currently handle the case where the initial hash
> table is under-sized due to the planner having underestimated things?
> Are the growth costs getting amortized by using an exponential growth
> function?

Yes. But that's still far from free.

Greetings,

Andres Freund

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Barbu Paul - Gheorghe 2019-08-21 07:30:36 Re: Erratically behaving query needs optimization
Previous Message Felix Geisendörfer 2019-08-20 17:55:56 Re: Extremely slow HashAggregate in simple UNION query