Re: master-detail relationship and count - Mailing list pgsql-sql

From Dan Langille
Subject Re: master-detail relationship and count
Date
Msg-id 3DE73255.29778.E71B8DFA@localhost
Whole thread Raw
In response to Re: master-detail relationship and count  (Achilleus Mantzios <achill@matrix.gatewaynet.com>)
List pgsql-sql
On 29 Nov 2002 at 13:16, Achilleus Mantzios wrote:

> On Fri, 29 Nov 2002, Gary Stainburn wrote:
> 
> > As you can see from the extract below, your statement has worked for all
> > landmarks that have links, but ignores any landmarks with out links.  How can
> > I adjust this so that all landmarks are listed, but with a zero count where
> > appropriate?
> 
> Then, use LEFT OUTER JOIN ... USING (),
> in combination with COALESCE().
> 
> (read the docs)

When it comes to outer joins, this page is quite useful:

http://www.postgresql.org/idocs/index.php?explicit-joins.html

I was reading it yesterday when improving the speed of some JOINs.  
The JOIN went from 3440ms to about 18ms when following the advice on 
that page.

I've put the queries and the explain output at 
http://www.freshports.org/tmp/outer-join.txt.  This will be an 
example of an OUTER JOIN but not the master-detail situation which 
occurs elsewhere in the database.

cheers

-- 
Dan Langille : http://www.langille.org/



pgsql-sql by date:

Previous
From: Rafal Kedziorski
Date:
Subject: import sql script
Next
From: Gary Stainburn
Date:
Subject: Re: master-detail relationship and count