Re: support for MERGE

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Daniel Westermann <dwe(at)dbi-services(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: support for MERGE
Date: 2022-05-18 12:30:05
Message-ID: 20220518123005.GA9638@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 11, 2022 at 11:33:50AM -0500, Justin Pryzby wrote:
> I suggest to reference the mvcc docs from the merge docs, or to make the merge
> docs themselves include the referenced information.

No comments here ?

> Also, EXPLAIN output currently looks like this:
>
> | Merge on ex_mtarget t (actual rows=0 loops=1)
> | Tuples Inserted: 0
> | Tuples Updated: 50
> | Tuples Deleted: 0
> | Tuples Skipped: 0
>
> Should the "zero" rows be elided from the text output ?
> And/or, should it use a more compact output format ?
>
> There are two output formats already in use, so the options would look like
> this:
>
> Tuples: Inserted: 1 Updated: 2 Deleted: 3 Skipped: 4
> or
> Tuples: inserted=1 updated=2 deleted=3 skipped=4
>
> Note double spaces and capitals.
> That's separate from the question about eliding zeros.

Actually, the existing uses suggest that these *aren't* separate.

The cases where 0 output is elided (like Heap Blocks and Buffers) uses "=" and
not ":". The cases using ":" always show all fields (Sort Method, Buckets,
Hits, Batches). I'm not sure which is preferable for MERGE, but here's one
way.

diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index b902ef30c87..491105263ff 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -4119,10 +4119,20 @@ show_modifytable_info(ModifyTableState *mtstate, List *ancestors,
skipped_path = total - insert_path - update_path - delete_path;
Assert(skipped_path >= 0);

- ExplainPropertyFloat("Tuples Inserted", NULL, insert_path, 0, es);
- ExplainPropertyFloat("Tuples Updated", NULL, update_path, 0, es);
- ExplainPropertyFloat("Tuples Deleted", NULL, delete_path, 0, es);
- ExplainPropertyFloat("Tuples Skipped", NULL, skipped_path, 0, es);
+ if (es->format == EXPLAIN_FORMAT_TEXT)
+ {
+ ExplainIndentText(es);
+ appendStringInfo(es->str,
+ "Tuples Inserted: %.0f Updated: %.0f Deleted: %.0f Skipped: %.0f\n",
+ insert_path, update_path, delete_path, skipped_path);
+ }
+ else
+ {
+ ExplainPropertyFloat("Tuples Inserted", NULL, insert_path, 0, es);
+ ExplainPropertyFloat("Tuples Updated", NULL, update_path, 0, es);
+ ExplainPropertyFloat("Tuples Deleted", NULL, delete_path, 0, es);
+ ExplainPropertyFloat("Tuples Skipped", NULL, skipped_path, 0, es);
+ }
}
}

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-05-18 13:30:26 Re: Minor improvements to test log navigability
Previous Message Ranier Vilela 2022-05-18 11:36:29 Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)