Re: [PERFORM] left join + case - how is it processed?

2009-01-18 Thread Chris
I thought the where condition would cut down on the rows returned, then the case statement would take effect to do the null check. It seems to be doing it in reverse ?? # explain analyze SELECT * from sq_vw_ast_perm where assetid='30748'; It aperas to me that both of your statements have whe

Re: [PERFORM] left join + case - how is it processed?

2009-01-18 Thread Evan Carroll
> My guess is you can exclude rows with WHERE if the the > column used is an run-time computation involving an ad-hoc CASE. * that you can't -- Evan Carroll System Lord of the Internets -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subs

Re: [PERFORM] left join + case - how is it processed?

2009-01-18 Thread Chris
The reason why the CASE is affecting your query planning is because you are using a query that compares assetid to a constant: SELECT * from sq_vw_ast_perm where assetid='30748'; When PostgreSQL evaluates this statement, assetid gets expanded either into a case statement (with your first view

Re: [PERFORM] left join + case - how is it processed?

2009-01-18 Thread Evan Carroll
On Sun, Jan 18, 2009 at 9:30 PM, Chris wrote: > Hi all, > > 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 >

Re: [PERFORM] left join + case - how is it processed?

2009-01-18 Thread Robert Haas
On Sun, Jan 18, 2009 at 10:30 PM, Chris wrote: > Hi all, > > 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 >

[PERFORM] left join + case - how is it processed?

2009-01-18 Thread Chris
Hi all, 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."gra