Re: Dropping a temporary view?

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Celia McInnis <celia(dot)mcinnis(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Erik Wienhold <ewie(at)ewie(dot)name>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Dropping a temporary view?
Date: 2024-03-21 11:41:13
Message-ID: CA+bJJbzTYvvigMDuaAgQ0fSaAozjfB+GbA9ATxW1u1UQLC0jqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 20 Mar 2024 at 21:01, Celia McInnis <celia(dot)mcinnis(at)gmail(dot)com> wrote:
> Correct. But the initial CREATE VIEW was done as a SELECT from the database, so if the create view was quick, I thought that the select from the view would be equally quick. Is this a faulty assumption?

It is. Create view does not run the query, select from the view does,

Create view is like compiling a function, it just checks, select from
the view is like running the function.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
s=> \timing
Timing is on.
s=> create temporary view tstview as select pg_sleep(1)::text;
CREATE VIEW
Time: 153.129 ms
s=> select * from tstview;
pg_sleep
----------

(1 row)

Time: 1009.195 ms (00:01.009)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Francisco Olarte.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2024-03-21 11:47:49 Re: Question about PostgreSQL upgrade from version 12 to version 15
Previous Message Dominique Devienne 2024-03-21 10:52:12 Re: pg_dumpall with flag --no-role-passwords omits roles comments as well