track_io_timing logging: Don't special case 0 ms.
authorPeter Geoghegan
Fri, 27 Aug 2021 20:33:58 +0000 (13:33 -0700)
committerPeter Geoghegan
Fri, 27 Aug 2021 20:33:58 +0000 (13:33 -0700)
Adjust track_io_timing related logging code added by commit 94d13d474d.
Make it consistent with other nearby autovacuum and autoanalyze logging
code by removing logic that suppressed zero millisecond outputs.

log_autovacuum_min_duration log output now reliably shows "read:" and
"write:" millisecond-based values in its report (when track_io_timing is
enabled).

Author: Peter Geoghegan 
Reviewed-By: Stephen Frost
Discussion: https://postgr.es/m/CAH2-WznW0FNxSVQMSRazAMYNfZ6DR_gr5WE78hc6E1CBkkJpzw@mail.gmail.com
Backpatch: 14-, where the track_io_timing logging was introduced.

src/backend/access/heap/vacuumlazy.c
src/backend/commands/analyze.c

index 7074b676d30d578e84474490c139e0a2604ccff6..49c054ca31ba7d66c772e83d07e408de30bb6f10 100644 (file)
@@ -840,16 +840,11 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
            }
            if (track_io_timing)
            {
-               appendStringInfoString(&buf, _("I/O timings:"));
-               if (pgStatBlockReadTime - startreadtime > 0)
-                   appendStringInfo(&buf, _(" read: %.3f ms"),
-                                    (double) (pgStatBlockReadTime - startreadtime) / 1000);
-               if ((pgStatBlockReadTime - startreadtime > 0) && (pgStatBlockWriteTime - startwritetime > 0))
-                   appendStringInfoString(&buf, _(","));
-               if (pgStatBlockWriteTime - startwritetime > 0)
-                   appendStringInfo(&buf, _(" write: %.3f ms"),
-                                    (double) (pgStatBlockWriteTime - startwritetime) / 1000);
-               appendStringInfoChar(&buf, '\n');
+               double      read_ms = (double) (pgStatBlockReadTime - startreadtime) / 1000;
+               double      write_ms = (double) (pgStatBlockWriteTime - startwritetime) / 1000;
+
+               appendStringInfo(&buf, _("I/O timings: read: %.3f ms, write: %.3f ms\n"),
+                                read_ms, write_ms);
            }
            appendStringInfo(&buf, _("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"),
                             read_rate, write_rate);
index a17349bcd6c8d6a522a09dc5dfd31d14356d9bcf..b31426e2b21fc00dc917073179b5177a6ae0143a 100644 (file)
@@ -779,16 +779,11 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
                             RelationGetRelationName(onerel));
            if (track_io_timing)
            {
-               appendStringInfoString(&buf, _("I/O timings:"));
-               if (pgStatBlockReadTime - startreadtime > 0)
-                   appendStringInfo(&buf, _(" read: %.3f ms"),
-                                    (double) (pgStatBlockReadTime - startreadtime) / 1000);
-               if ((pgStatBlockReadTime - startreadtime > 0) && (pgStatBlockWriteTime - startwritetime > 0))
-                   appendStringInfoString(&buf, _(","));
-               if (pgStatBlockWriteTime - startwritetime > 0)
-                   appendStringInfo(&buf, _(" write: %.3f ms"),
-                                    (double) (pgStatBlockWriteTime - startwritetime) / 1000);
-               appendStringInfoChar(&buf, '\n');
+               double      read_ms = (double) (pgStatBlockReadTime - startreadtime) / 1000;
+               double      write_ms = (double) (pgStatBlockWriteTime - startwritetime) / 1000;
+
+               appendStringInfo(&buf, _("I/O timings: read: %.3f ms, write: %.3f ms\n"),
+                                read_ms, write_ms);
            }
            appendStringInfo(&buf, _("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"),
                             read_rate, write_rate);