Re: Strange left outer join performance issue

From: Tom Lane
Subject: Re: Strange left outer join performance issue
Date: ,
Msg-id: 25685.1174688032@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Strange left outer join performance issue  ("Noah M. Daniels")
Responses: Re: Strange left outer join performance issue  ("Noah M. Daniels")
List: pgsql-performance

Tree view

Strange left outer join performance issue  ("Noah M. Daniels", )
 Re: Strange left outer join performance issue  ("Daniel Cristian Cruz", )
  Re: Strange left outer join performance issue  ("Noah M. Daniels", )
 Re: Strange left outer join performance issue  (Tom Lane, )
  Re: Strange left outer join performance issue  ("Noah M. Daniels", )
   Re: Strange left outer join performance issue  (Tom Lane, )

"Noah M. Daniels" <> writes:
> I have two queries that are very similar, that run on the same table
> with slightly different conditions. However, despite a similar number
> of rows returned, the query planner is insisting on a different
> ordering and different join algorithm, causing a huge performance
> hit. I'm not sure why the planner is doing the merge join the way it
> is in the slow case, rather than following a similar plan to the fast
> case.

It likes the merge join because it predicts (apparently correctly) that
only about 1/14th of the table will need to be scanned.  This'd be an
artifact of the relative ranges of supplier ids in the two tables.

What PG version is this?  8.2 understands about repeated indexscans
being cheaper than standalone ones, but I get the impression from the
explain estimates that you may be using something older that's
overestimating the cost of the nestloop way.

            regards, tom lane


pgsql-performance by date:

From: "Kevin Grittner"
Date:
Subject: Re: [HACKERS] EXISTS optimization
From: "amrit angsusingh"
Date:
Subject: Optimization postgresql 8.1.4 FC 6 X64 ?