From: Tom Lane <tgl@sss.pgh.pa.us>
To: rm_pg@cheapcomplexdevices.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Left Outer Join much faster than non-outer Join?
Date: Wed, 30 Mar 2005 23:07:52 -0500
Message-ID: <1755.1112242072@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.58.0503301219540.9713@greenie.cheapcomplexdevices.com>
References: <Pine.LNX.4.58.0503301219540.9713@greenie.cheapcomplexdevices.com>
rm_pg@cheapcomplexdevices.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, rm_pg@cheapcomplexdevices.com
Subject: Re: Left Outer Join much faster than non-outer Join?
In-Reply-To: <1755.1112242072@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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