Re: - Slow Query - Mailing list pgsql-performance

From Віталій Тимчишин
Subject Re: - Slow Query
Date
Msg-id 331e40660907030422p2375a09co827457c2dc7aff4c@mail.gmail.com
Whole thread Raw
In response to Re: - Slow Query  (Mike Ivanov <mikei@activestate.com>)
Responses Re: - Slow Query
List pgsql-performance


2009/7/1 Mike Ivanov <mikei@activestate.com>


> LEFT outer JOIN ville ON ville.uid = bien.ref_ville
> LEFT outer JOIN freguesia_ville ON freguesia_ville.ref_ville =ville.uid

This is not enough. You have to add this condition as well:

AND bien.ref_ville = freguesia_ville.ref_ville

In other words, when you link three tables by a common field, all three relationships should be explicitly expressed, otherwise you'll have this type of explosive row multiplication.

Why so? Is not changing "freguesia_ville.ref_ville =ville.uid" to "freguesia_ville.ref_ville =bien.uid" enough (to prevent cases when ville.uid is null as result of join)?


pgsql-performance by date:

Previous
From: Sergei Politov
Date:
Subject: Most effective insert or replace
Next
From: Matthew Wakeling
Date:
Subject: Re: Most effective insert or replace