Re: left join + case - how is it processed? - Mailing list pgsql-performance

From Richard Broersma
Subject Re: left join + case - how is it processed?
Date
Msg-id [email protected]
Whole thread Raw
In response to left join + case - how is it processed?  (Chris <[email protected]>)
List pgsql-performance
On Sun, Jan 18, 2009 at 7:30 PM, Chris <[email protected]> wrote:

> I have a view that looks like this:
>
>  SELECT
>        CASE
>            WHEN r.assetid IS NULL THEN p.assetid
>            ELSE r.assetid
>        END AS assetid,
>        CASE
>            WHEN r.userid IS NULL THEN p.userid
>            ELSE r.userid
>        END AS userid, p.permission, p."granted", p.cascades
>   FROM sq_ast_perm p
>   LEFT JOIN sq_vw_ast_role r ON r.roleid::text = p.userid::text AND
> r.assetid::text = p.assetid::text;

The effect that you are trying to achieve with CASE statements is
better suited to the COALESCE(...) function.
http://www.postgresql.org/docs/8.3/interactive/functions-conditional.html#AEN14484

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: left join + case - how is it processed?
Next
From: Akos Gabriel
Date:
Subject: test