Re: materialization blocks hash join

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: materialization blocks hash join
Date: 2020-03-30 17:13:15
Message-ID: 21050.1585588395@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> writes:
> That's because eqjoinsel_inner won't have any statistics for either side
> of the join, so it'll use default ndistinct values (200), resulting in
> estimate of 0.5% for the join condition.

Right.

> But this should not affect the choice of join algorithm, I think,
> because that's only the output of the join.

Lack of stats will also discourage use of a hash join, because the
default assumption in the absence of stats is that the join column
has a pretty non-flat distribution, risking clumping into a few
hash buckets. Merge join is less sensitive to the data distribution
so it tends to come out as preferred in such cases.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Turelinckx 2020-03-30 17:23:42 Re: snapper vs. HEAD
Previous Message Corey Huinker 2020-03-30 17:10:19 Re: Add A Glossary