Re: BUG #6668: hashjoin cost problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: postgresuser(at)yahoo(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6668: hashjoin cost problem
Date: 2012-05-31 05:03:24
Message-ID: 28259.1338440604@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

postgresuser(at)yahoo(dot)com writes:
> create table small(i) as select (g/1000) * 1000 from
> generate_series(1,10000) g;
> create table large(i) as select generate_series(1,100000000);

> It doesn't matter how big the big table is... for this distribution large
> table is hashed.

I don't think that's wrong. If it hashes the small table, there cannot
be less than 1000 entries on each populated hash chain; adding more
work_mem doesn't help. The planner is designed to avoid hashing such
unfriendly distributions as that. The fact that you can get a somewhat
smaller runtime by forcing hashing in the other direction suggests that
its cost factors are not quite right for your specific case --- but it's
a long way from that observation to deciding that we should change the
cost factors for everyone. In any case, the sizes of the tables are not
the only determinant of which one should be hashed.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message jose.soares 2012-05-31 05:25:24 BUG #6669: unique index w/ multiple columns and NULLs
Previous Message Edmund Horner 2012-05-31 02:14:27 9.2 beta1 libxml2 can't be loaded on Windows