Re: Hash aggregate collisions cause excessive spilling - Mailing list pgsql-hackers

From Ants Aasma
Subject Re: Hash aggregate collisions cause excessive spilling
Date
Msg-id CANwKhkOZuf8ychD3b=8-+-hxyu+OjOCU56AesbHiDqpRmARc0w@mail.gmail.com
Whole thread
In response to Re: Hash aggregate collisions cause excessive spilling  (Ants Aasma <ants.aasma@cybertec.at>)
Responses Re: Hash aggregate collisions cause excessive spilling
List pgsql-hackers
On Thu, 19 Feb 2026 at 20:07, Ants Aasma <ants.aasma@cybertec.at> wrote:
> I was thinking more along the lines of hashing together the pointer
> value and worker number. But something more deterministic would indeed
> be better. How about this?
>
> --- a/src/backend/executor/execGrouping.c
> +++ b/src/backend/executor/execGrouping.c
> @@ -201,3 +201,3 @@ BuildTupleHashTable(PlanState *parent,
>         MemoryContext oldcontext;
> -       uint32          hash_iv = 0;
> +       uint32          hash_iv = parent->plan->plan_node_id;

I can confirm that this fixes the issue. A standalone reproducer is here:

create table data as select random(1,1000000) from generate_series(1,10000000);
vacuum analyze data;
set enable_gathermerge = off;
explain analyze select distinct random from data;

Regards,
Ants Aasma



pgsql-hackers by date:

Previous
From: Sami Imseih
Date:
Subject: Re: Optional skipping of unchanged relations during ANALYZE?
Next
From: Andres Freund
Date:
Subject: Re: Adding locks statistics