Re: Left Outer Join much faster than non-outer Join?

From: Tom Lane
Subject: Re: Left Outer Join much faster than non-outer Join?
Date: ,
Msg-id: 1755.1112242072@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Left Outer Join much faster than non-outer Join?  ()
Responses: Re: Left Outer Join much faster than non-outer Join?  (Ron Mayer)
List: pgsql-performance

Tree view

Left Outer Join much faster than non-outer Join?  (, )
 Re: Left Outer Join much faster than non-outer Join?  (Ron Mayer, )
 Re: Left Outer Join much faster than non-outer Join?  (Tom Lane, )
  Re: Left Outer Join much faster than non-outer Join?  (Ron Mayer, )
   Re: Left Outer Join much faster than non-outer Join?  (Ron Mayer, )
    Re: Left Outer Join much faster than non-outer Join?  (Simon Riggs, )
 Re: Left Outer Join much faster than non-outer Join?  ("Patrick Vedrines", )

 writes:
>  select *
>      from streetname_lookup as sl
>      join city_lookup as cl on (true)
>      left outer join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and
cl.geo_city_id=ts.geo_city_id)
>      where  str_name='alamo' and  city='san antonio' and state='TX'
> ;

That's a fairly odd query; why don't you have any join condition between
streetname_lookup and city_lookup?

The planner won't consider Cartesian joins unless forced to, which is
why it fails to consider the join order "((sl join cl) join ts)" unless
you have an outer join in the mix.  I think that's generally a good
heuristic, and am disinclined to remove it ...

            regards, tom lane


pgsql-performance by date:

From: PFC
Date:
Subject: Re: fine tuning for logging server
From: Richard_D_Levine@Raytheon.com
Date:
Subject: Re: Reading recommendations