pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #5834: Planner - cost for hash scan too small
2+ messages / 2 participants
[nested] [flat]

* BUG #5834: Planner - cost for hash scan too small
@ 2011-01-13 09:07  Pasman <pasman.p@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Pasman @ 2011-01-13 09:07 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      5834
Logged by:          Pasman
Email address:      pasman.p@gmail.com
PostgreSQL version: 8.4.6
Operating system:   WinXP sp2
Description:        Planner - cost for hash scan too small
Details: 

Postgres not estimate cost of creating hash index
when it plans hash join. Use case:

create table test1 as
select i,'aaaaaaaaaa'::text as t1 from generate_series(1,10000) g(i);
analyze test1;

create table test2 as
select i,'aaaaaaaaaa'::text as t2 from generate_series(1,10000) g(i);
analyze test2;

explain analyze 
select * from test1 natural join test2;

"Hash Join  (cost=280.00..685.00 rows=10000 width=26) (actual
time=48.914..125.526 rows=10000 loops=1)"
"  Hash Cond: (test1.i = test2.i)"
"  ->  Seq Scan on test1  (cost=0.00..155.00 rows=10000 width=15) (actual
time=0.032..21.693 rows=10000 loops=1)"
"  ->  Hash  (cost=155.00..155.00 rows=10000 width=15) (actual
time=48.835..48.835 rows=10000 loops=1)"
"        ->  Seq Scan on test2  (cost=0.00..155.00 rows=10000 width=15)
(actual time=0.018..24.045 rows=10000 loops=1)"
"Total runtime: 146.291 ms"


Cost for creating hash (155.00) is equal to 
cost of sequential scan on test2 but 
real time is 2 times bigger. 

I think that cost of Hash node ought to include costs of calculating hash
function and inserting tuple into index:

cost of seq scan 
+ numtuples*cpu_operator_cost 
+ numtuples*cpu_index_tuple_cost



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #5834: Planner - cost for hash scan too small
@ 2011-01-13 18:09  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Pasman <pasman.p@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2011-01-13 18:09 UTC (permalink / raw)
  To: Pasman <pasman.p@gmail.com>; +Cc: pgsql-bugs

"Pasman" <pasman.p@gmail.com> writes:
> Postgres not estimate cost of creating hash index
> when it plans hash join. Use case:

Yes, it does figure those costs, but they're just folded into the cost
of the hashjoin.  The numbers shown for the Hash subnode are only
cosmetic.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-01-13 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-01-13 09:07 BUG #5834: Planner - cost for hash scan too small Pasman <pasman.p@gmail.com>
2011-01-13 18:09 ` Tom Lane <tgl@sss.pgh.pa.us>

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