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

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: 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-24 04:47:54
Message-ID: CAGRkXqRCLftV+qAs7pX09pug0ePUpodOdGY_azLnGHA4z-cKqA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi David,

The patch fixes the cases from the report for me. Two small things.

1. simplehash rounds the size up to a power of 2, so the empty table
can still be twice hash_mem. With work_mem = 1GB, a plain EXPLAIN of
the recursive query zeroes 4 GB. Halving the limit fixes it.
hash_choose_num_buckets() does the same.

2. Plain EXPLAIN still builds the table. nodeAgg skips it.

The attached patch on top of yours does both.

Thanks,
Shihao

Attachment Content-Type Size
nocfbot-reduce-mem.patch application/octet-stream 2.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tatsuo Ishii 2026-10-24 07:51:48 Re: first_value()/nth_value() with IGNORE NULLS loop forever (EXCLUDE GROUP/TIES, frame past partition end, no ORDER BY)
Previous Message shihao zhong 2026-10-24 04:41:55 Re: BUG #19519: REPACK can fail due to missing chunk for toast value