Re: Hash or merge join instead of inner loop

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jim(at)nasby(dot)net
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Hash or merge join instead of inner loop
Date: 2003-06-10 06:15:11
Message-ID: 274.1055225711@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> I have a query that's cauing pgsql choose either a hash or merge join
> depending on how I mess with the stats variables, but it won't choose an
> nested loop, even though it's the fastest.

There's been some discussion about that before; you could check the
archives (now that they're up again ;-)). I believe that the planner
overestimates the cost of a nestloop with inner indexscan, because it
costs the indexscans as though each one is an independent ab-initio
index search. In reality, most of the upper btree levels will no doubt
stay in memory during such a query, and so this estimate charges many
more reads than really occur. Fixing this is on the todo list, but no
one's got to it yet. (It's not clear to me how to put the consideration
into the planner's cost algorithms in a clean way.)

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Shridhar Daithankar 2003-06-10 08:56:17 Re: Hash or merge join instead of inner loop
Previous Message Shridhar Daithankar 2003-06-10 05:15:25 Re: FW: [ADMIN] Shared_buffers and kernel parameters, tuning