pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Postgres User <postgresuser@yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #6668: hashjoin cost problem
Date: Wed, 30 May 2012 22:57:17 -0700 (PDT)
Message-ID: <1338443837.61025.YahooMailNeo@web121105.mail.ne1.yahoo.com> (raw)
In-Reply-To: <28259.1338440604@sss.pgh.pa.us>
References: <E1SZtC5-00028E-DI@wrigleys.postgresql.org>
	<28259.1338440604@sss.pgh.pa.us>

Why is cost_hashjoin estimating 50 billion tuple comparisons for 10K rows of output though?



________________________________
 From: Tom Lane <tgl@sss.pgh.pa.us>
To: postgresuser@yahoo.com 
Cc: pgsql-bugs@postgresql.org 
Sent: Wednesday, May 30, 2012 10:03 PM
Subject: Re: [BUGS] BUG #6668: hashjoin cost problem 
 
postgresuser@yahoo.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

view thread (4+ messages)  latest in thread

Message-ID: <1338443837.61025.YahooMailNeo@web121105.mail.ne1.yahoo.com>
Permalink:  ../1338443837.61025.YahooMailNeo@web121105.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/1338443837.61025.YahooMailNeo@web121105.mail.ne1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: postgresuser@yahoo.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #6668: hashjoin cost problem
  In-Reply-To: <1338443837.61025.YahooMailNeo@web121105.mail.ne1.yahoo.com>
  References: <E1SZtC5-00028E-DI@wrigleys.postgresql.org> <28259.1338440604@sss.pgh.pa.us> <1338443837.61025.YahooMailNeo@web121105.mail.ne1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox