From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Ted Yu <yuzhihong(at)gmail(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: MERGE ... WHEN NOT MATCHED BY SOURCE |
Date: | 2023-02-07 10:28:42 |
Message-ID: | CAEZATCWdnEjzKAb7JB4Af5_wgitEiT2hCpMeCMPBPjm4QA1npg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, 21 Jan 2023 at 14:18, Ted Yu <yuzhihong(at)gmail(dot)com> wrote:
>
> On Sat, Jan 21, 2023 at 3:05 AM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>>
>> Rebased version, following 8eba3e3f02 and 5d29d525ff.
>>
Another rebased version attached.
> In transform_MERGE_to_join :
>
> + if (action->matchKind == MERGE_WHEN_NOT_MATCHED_BY_SOURCE)
> + tgt_only_tuples = true;
> + if (action->matchKind == MERGE_WHEN_NOT_MATCHED_BY_TARGET)
>
> There should be an `else` in front of the second `if`.
> When tgt_only_tuples and src_only_tuples are both true, we can come out of the loop.
>
I decided not to do that. Adding an "else" doesn't change the code
that the compiler generates, and IMO it's slightly more readable
without it, since it keeps the line length shorter, and the test
conditions aligned, but that's a matter of opinion / personal
preference.
I think adding extra logic to exit the loop early if both
tgt_only_tuples and src_only_tuples are true would be a premature
optimisation, increasing the code size for no real benefit. In
practice, there are unlikely to be more than a few merge actions in
the list.
Regards,
Dean
Attachment | Content-Type | Size |
---|---|---|
support-merge-when-not-matched-by-source-v6.patch | text/x-patch | 40.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2023-02-07 10:29:50 | Re: Too coarse predicate locks granularity for B+ tree indexes |
Previous Message | Rinat Shigapov | 2023-02-07 10:23:54 | Too coarse predicate locks granularity for B+ tree indexes |