Alessio Bragadini <alessio@albourne.com> writes:
> Tom Lane wrote:
>> One must wonder why you create views at all, if you don't intend them
>> to stick around for long. Why not just write out the SELECTs in full?
>> (If you think there's some performance benefit to using a view, you are
>> quite mistaken.)
> There are no cached query plans in any way?
Certainly none associated with views. Views would make a very poor
basis for caching plans, since they typically form only a part of
the eventual query. Example: suppose you write
create view v as select * from foo;
select * from v where indexedcol = 42;
You'd be fairly unhappy if the system were unable to use an indexscan
over foo.indexedcol for this query, no? But a plan associated with the
bare view definition couldn't exploit this possibility, because the
potential to use that index doesn't arise in the context of the view
itself, only in the context of the complete query.
regards, tom lane