Thread: PgAmin view

PgAmin view

From
Shaozhong SHI
Date:
If a PgAmin view is created and tables it queries are missing, what will happen?

If a PdAmin view is created, and it may take 20 hours to complete, what will happen?

Would views automatically run, when you start the PgAmin?

Regards,

David

Re: PgAmin view

From
"David G. Johnston"
Date:


On Thursday, October 26, 2023, Shaozhong SHI <shishaozhong@gmail.com> wrote:
If a PgAmin view is created and tables it queries are missing, what will happen?

If a PdAmin view is created, and it may take 20 hours to complete, what will happen?

Would views automatically run, when you start the PgAmin?


Test it with a view that takes seconds to run.

David J. 

Re: PgAmin view

From
Adrian Klaver
Date:
On 10/26/23 03:56, Shaozhong SHI wrote:
> If a PgAmin view is created and tables it queries are missing, what will 
> happen?

Easy enough to test:

create view test_vw as select * from non_existent_table;
ERROR:  relation "non_existent_table" does not exist
LINE 1: create view test_vw as select * from non_existent_table;

> 
> If a PdAmin view is created, and it may take 20 hours to complete, what 
> will happen?


Docs:

https://www.postgresql.org/docs/current/sql-createview.html

"CREATE VIEW defines a view of a query. The view is not physically 
materialized. Instead, the query is run every time the view is 
referenced in a query."

> 
> Would views automatically run, when you start the PgAmin?


See above. The view query will not execute until specifically asked for 
and nothing I have seen in my limited use of pgAdmin does that 
automatically.

> 
> Regards,
> 
> David

-- 
Adrian Klaver
adrian.klaver@aklaver.com




Re: PgAmin view

From
Merlin Moncure
Date:
On Thu, Oct 26, 2023 at 5:56 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:
If a PgAmin view is created and tables it queries are missing, what will happen?

If a PdAmin view is created, and it may take 20 hours to complete, what will happen?

Would views automatically run, when you start the PgAmin?

Views are rewritten into the query when the query is planned.  

merlin