| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> | 
|---|---|
| To: | Michael Lewis <mlewis(at)entrata(dot)com> | 
| Cc: | Mithran Kulasekaran <mithranakulasekaran(at)gmail(dot)com>, Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: Postgres views cannot use both union and join/where | 
| Date: | 2021-10-20 03:38:40 | 
| Message-ID: | CAKFQuwZ+L+HLFs0Fdz2W4NYYxxk6Ko1CMQFyo-c1-ba-VuqDkA@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-performance | 
On Tuesday, October 19, 2021, Michael Lewis <mlewis(at)entrata(dot)com> wrote:
> On Tue, Oct 19, 2021 at 3:48 PM Mithran Kulasekaran <
> mithranakulasekaran(at)gmail(dot)com> wrote:
>
>> create  view template_view (id, name, description, is_staged) as
>> select t.id,t.name, t.description, false as is_staged
>> from template t
>>          left join template_staging ts on t.name = ts.name and ts.name is null
>>
>>
> Does that work? I've only seen that type of logic written as-
>
> left join template_staging ts on t.name = ts.name
> where ts.name is null
>
The are functionally equivalent, though the timing of the expression
evaluation differs slightly.
It could also be written as an anti-join:
Select * from template as t where not exists (select 1 from
template_staging as ts where t.name = ts.name)
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashkil Dighin | 2021-10-20 10:51:38 | Re: Lock contention high | 
| Previous Message | Michael Lewis | 2021-10-20 02:56:33 | Re: Postgres views cannot use both union and join/where |