I've been reading carefully links such as the below two:
Will Postgres push down a WHERE clause into a VIEW with a Window Function (Aggregate)?
https://dba.stackexchange.com/questions/151169/are-views-harmful-for-performance-in-postgresql
There are comments made in the above links that suggest answers to two related questions I have, but I'd like to make sure I understand.
Suppose I have a view:
create view A as
select
x.xKey,
x.y,
x.z,
y.yKey,
y.a,
y.b
from x
join y
on x.xKey = y.xKey
And now I have another...
create view B as
select
A.xKey,
A.y,
A.z,
A.yKey,
A.a,
A.b,
r.rKey,
r.n
from A
join r
on A.yKey = r.yKey
Assume a third view C that does more of the same, but all three views being plain select statements.
Two questions:
If I select from view C using filters that relate to any/all of the tables involved, are "predicates" always "pushed down" (new phrase for me, hoping I said this properly) so that view C is as efficient filter-wise as would be a larger stand-alone query built the same way?
If I select from view C but I do not utilize all tables involved in all of the joins, that is where I do pay a price that could be avoided by a hand-crafted select statement that joined fewer tables. Yes?
Thanks much in advance for thoughts.