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); + } } }