Skip to content
 

PostgreSQL banter on ‘with’

PostgreSQL_logo.3colors.120x120
RhodiumToad with foo(x) as (values (‘blah blah blah’)) insert into wherever select x from foo;
merlinm or, with vars as (select ‘a’ as a, 2 as b) insert into foo values (select a from vars), select b from vars);
merlinm oops, missing a parent there
merlinm gah
RhodiumToad with vars(a,b) as (values (‘a’, 2)) …
merlinm ah, touche
darkblue_b with .. is a ‘materialized subselect’ under the hood ?
RhodiumToad yes
strk not really materialized, but yes
RhodiumToad it is materialized
strk doesn’t persist,is what I mean
strk not after the statement
darkblue_b ah – its a temporary table… perhaps
RhodiumToad no
darkblue_b ok – well I dont want to waste your time.. just grasping at things.
strk darkblue_b: only exists during the single statement
darkblue_b yes I read that
RhodiumToad it exists only within the scope of the query and it can’t have indexes, but it is materialized in that it is evaluated at most once (lazily)
darkblue_b writes that down