Re: joining views - Mailing list pgsql-performance

From Tomasz Myrta
Subject Re: joining views
Date
Msg-id 3DB6BA0A.4060502@klaster.net
Whole thread Raw
In response to joining views  (Tomasz Myrta <jasiek@klaster.net>)
List pgsql-performance
Użytkownik Tom Lane napisał:

> I think this is the same issue that Stephan identified in his response
> to your other posting ("sub-select with aggregate").  When you write
>     FROM x join y using (col) WHERE x.col = const
> the WHERE-restriction is only applied to x.  I'm afraid you'll need
> to write
>     FROM x join y using (col) WHERE x.col = const AND y.col = const
> Ideally you should be able to write just
>     FROM x join y using (col) WHERE col = const
> but I think that will be taken the same as "x.col = const" :-(

I am sad, but you are right. Using views this way will look strange:

create view v3 as select
  v1.id as id1,
  v2.id as id2,
  ...
from some_view v1, another_view v2;

select * from v3 where
id1=1234 and id2=1234;

Is it possible to make it look better?

And how to pass param=const to subquery ("sub-select with aggregate") if
I want to create view with this query?
Tomasz Myrta


pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: joining views
Next
From: Terry Yapt
Date:
Subject: Basic question about indexes/explain