Re: Confusing reference to MERGE use inside WITH

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: rasmus(at)porsager(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Confusing reference to MERGE use inside WITH
Date: 2023-07-17 01:16:58
Message-ID: CACJufxHb9fZfj2GPT=4Jr_oJ7h=XZVhuMqm0yk-yszoxM5G+LQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Sun, Jul 16, 2023 at 8:48 PM PG Doc comments form
<noreply(at)postgresql(dot)org> wrote:
>
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/15/queries-with.html
> Description:
>
> Hi.
>
> In the queries WITH documentation
> https://www.postgresql.org/docs/15/queries-with.html it is a bit confusing
> that MERGE is referenced in several places as being something you can use
> inside with, even though it can't.
>
> If you search for MERGE on the page, you will find the 2 first results is a
> reference saying MERGE can be used inside WITH, the same as SELECT, INSERT,
> UPDATE, or DELETE. The 3rd result then correctly states that MERGE cannot be
> used inside WITH.
>
> If I'm misunderstanding the meaning of the first 2 results, then I apologise
> :)
>
> Greetings
> Rasmus Porsager

I agree. The second one is kind of confusing.

> WITH w AS (
> SELECT key, very_expensive_function(val) as f FROM some_table
> )
> SELECT * FROM w AS w1 JOIN w AS w2 ON w1.f = w2.f;
> Here, materialization of the WITH query ensures that very_expensive_function is evaluated only once per table row, not twice.
> The examples above only show WITH being used with SELECT, but it can be attached in the same way to INSERT, UPDATE, DELETE, > or MERGE.

There are two "SELECT". " only show WITH being used with SELECT",
not mention of "SELECT" refer to the auxiliary statements or primary
statements.

--
I recommend David Deutsch's <<The Beginning of Infinity>>

Jian

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2023-07-17 01:48:17 Re: Confusing reference to MERGE use inside WITH
Previous Message PG Doc comments form 2023-07-15 14:37:00 Confusing reference to MERGE use inside WITH