Re: BUG #19708: Hash Join becomes about 300x slower with higher work_mem

From: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, yanarnold5(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, tomas(at)vondra(dot)me
Subject: Re: BUG #19708: Hash Join becomes about 300x slower with higher work_mem
Date: 2026-09-22 04:34:57
Message-ID: CAE8JnxMYkkTmsyBs8PzEr4fWXD9zpJZpBeuRhCo9oBzh__G==Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Sep 22, 2026 at 12:31 AM shihao zhong <zhong950419(at)gmail(dot)com> wrote:

>
> > Indeed. So I think this is an uninteresting contrived case.
>
> I agree the reproducer is contrived, and that assuming
> 10 pages for a never vacuumed table is the right call.
>
> My concern is that ANALYZE does not always get us out of it. The
> n_distinct estimator is known to undershoot on long tailed columns.
>
> I did a mini benchmark:
>
> Take a 5M row orders table where half the rows come from 1000 big
> customers
> and half from one time customers. Right after ANALYZE it gets n_distinct
> 31846, against a true value of 2.5M. A join of two such tables is
> estimated at 780M rows and returns 2.5M. That is one join, and each
> further join multiplies the error.
>

True, that sort of error should compound over multiple joins, and so the
number
of rows.

Could you include your script?

> So the same shape comes out of fresh statistics on an ordinary schema,
> and the extra cost only appeared in 18. That is why I think it is worth
> handling.
>

Regards,
Alexandre

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Borodin 2026-09-22 06:15:50 Re: BUG #19700: PostgreSQL: an SP-GiST index on `inet` makes IPv6 rows invisible
Previous Message PG Bug reporting form 2026-09-22 01:26:24 BUG #19711: SSH tunnel with PPK identity file fails/crashes in newer pgAdmin version but works in older version