Re: Lazy View's Column Computing

2021-08-02 Thread Tom Lane
Mladen Gogala writes: > The query from the view would probably merge view  with the original and > optimize everything as a single query. Unfortunately, there is no way to > tell: > mgogala=# explain select ename,job,sal from acct_view; > QUERY PLAN > -

Re: Lazy View's Column Computing

2021-08-02 Thread Mladen Gogala
For all that we know, it may already be happening. That looks like a pretty reasonable optimization which may already be in place. If we create a view: mgogala=# select * from dept;  deptno |   dname    |   loc ++-- 10 | ACCOUNTING | NEW YORK 20 | RESEARCH 

Re: Lazy View's Column Computing

2021-08-02 Thread Vijaykumar Jain
On Mon, 2 Aug 2021 at 19:53, Tom Lane wrote: > Avi Weinberg writes: > > Is there a way to compute a column in a view only if it is referenced in > the query? I have a view's column that its value is computed by a > function. If in the query that column is not used at all, can Postgres > "skip"

Re: Lazy View's Column Computing

2021-08-02 Thread Tom Lane
Avi Weinberg writes: > Is there a way to compute a column in a view only if it is referenced in the > query? I have a view's column that its value is computed by a function. If > in the query that column is not used at all, can Postgres "skip" computing it? If the function is not volatile, an

Lazy View's Column Computing

2021-08-02 Thread Avi Weinberg
Hi, Is there a way to compute a column in a view only if it is referenced in the query? I have a view's column that its value is computed by a function. If in the query that column is not used at all, can Postgres "skip" computing it? Thanks! IMPORTANT - This email and any attachments is inte