Re: Postgresq 8,1 hangs when running function - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Postgresq 8,1 hangs when running function
Date
Msg-id 20060821125903.GA24063@winnie.fuhr.org
Whole thread Raw
In response to Re: Postgresq 8,1 hangs when running function  (Sean Davis <sdavis2@mail.nih.gov>)
Responses Re: Postgresq 8,1 hangs when running function  ("ben sewell" <mosherben@gmail.com>)
List pgsql-novice
On Mon, Aug 21, 2006 at 08:37:21AM -0400, Sean Davis wrote:
> If your SQL from your function has the same behavior when you execute it, it
> is likely one of two problems:
>
> 1)  You are doing an unconstrained CROSS JOIN and getting a large result set

Check the parentheses around the OR expressions in the queries'
WHERE clauses.  The queries have their join conditions separated
by AND and then an OR that looks like it needs an extra set of
parentheses.  That is, instead of this:

  AND cond1 AND cond2 AND (cond3 AND cond4) OR (cond5 AND cond6)

try this:

  AND cond1 AND cond2 AND ((cond3 AND cond4) OR (cond5 AND cond6))

or

  AND cond1 AND cond2 AND (cond3 AND cond4 OR cond5 AND cond6)

Otherwise, as Sean said, you're getting cross joins.

--
Michael Fuhr

pgsql-novice by date:

Previous
From: Sean Davis
Date:
Subject: Re: Postgresq 8,1 hangs when running function
Next
From: "ben sewell"
Date:
Subject: Re: Postgresq 8,1 hangs when running function