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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: rm_pg(at)cheapcomplexdevices(dot)com
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Left Outer Join much faster than non-outer Join?
Date: 2005-03-31 04:07:52
Message-ID: 1755.1112242072@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

rm_pg(at)cheapcomplexdevices(dot)com 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Ron Mayer 2005-03-31 07:04:53 Re: Left Outer Join much faster than non-outer Join?
Previous Message John Arbash Meinel 2005-03-31 02:41:43 Re: fine tuning for logging server