Re: BUG #19759: Hashed SetOp / RecursiveUnion pre-allocate up to 64 GB from the row estimate since 8f29467c57f

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: alpkeles99(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #19759: Hashed SetOp / RecursiveUnion pre-allocate up to 64 GB from the row estimate since 8f29467c57f
Date: 2026-10-19 08:36:25
Message-ID: CAApHDvrJ4AeNpBJdRXbpDx1M8YOG-+zN+4keUrCDChw4xD=1CQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, 16 Oct 2026 at 02:47, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> Since commit 8f29467c57f ("Change "long" numGroups fields to be Cardinality
> (i.e., double)", 2025-11-02), BuildTupleHashTable() no longer limits the
> initial size of a TupleHashTable to hash_mem. Its new comment says that
> staying within hash_mem is the caller's job. But nodeRecursiveunion.c and
> nodeSetOp.c pass the planner's raw group estimate, so the executor now
> allocates and zeroes a bucket array of up to 2^32 entries x 16 bytes =
> 64 GB in ExecInit, before reading a single row, whenever the estimate is
> large. PostgreSQL 18 is not affected (it capped nbuckets at
> get_hash_memory_limit() / entrysize). The commit is in REL_19_BETA1
> through REL_19_RC1.

I've added an open item for this to ensure it's not forgotten.

David

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2026-10-19 10:09:57 Re: Inconsistency in psql output with \d+x PATTERN
Previous Message Staroverov Ilja 2026-10-19 05:16:42 Re: pg_stat_statements replaces SQL/JSON ON EMPTY / ON ERROR keywords with parameters