]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add information about WAL buffers being full to EXPLAIN (WAL)
authorMichael Paquier <michael@paquier.xyz>
Mon, 17 Feb 2025 05:50:33 +0000 (14:50 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 17 Feb 2025 05:50:33 +0000 (14:50 +0900)
This is similar to ce5bcc4a9f26, relying on the addition of
wal_buffers_full to WalUsage.  This time, the information is added to
the output generated by EXPLAIN (WAL).

Author: Bertrand Drouvot
Reviewed-by: Ilia Evdokimov
Discussion: https://postgr.es/m/Z6SOha5YFFgvpwQY@ip-10-97-1-34.eu-west-3.compute.internal

doc/src/sgml/ref/explain.sgml
src/backend/commands/explain.c

index 6361a14e65d062b405fb27d7d36c65a69e6a628b..652ece7213a12f7c8a88ae01a96a1626853a33d6 100644 (file)
@@ -242,8 +242,9 @@ ROLLBACK;
     <listitem>
      <para>
       Include information on WAL record generation. Specifically, include the
-      number of records, number of full page images (fpi) and the amount of WAL
-      generated in bytes. In text format, only non-zero values are printed.
+      number of records, number of full page images (fpi), the amount of WAL
+      generated in bytes and the number of times the WAL buffers became full.
+      In text format, only non-zero values are printed.
       This parameter may only be used when <literal>ANALYZE</literal> is also
       enabled.  It defaults to <literal>FALSE</literal>.
      </para>
index c24e66f82e1cedbe4a84aa6ad39412c95bdfc7cc..dc4bef9ab81b5d19e6b96ab155538fbc28a11782 100644 (file)
@@ -4242,7 +4242,7 @@ show_wal_usage(ExplainState *es, const WalUsage *usage)
        {
                /* Show only positive counter values. */
                if ((usage->wal_records > 0) || (usage->wal_fpi > 0) ||
-                       (usage->wal_bytes > 0))
+                       (usage->wal_bytes > 0) || (usage->wal_buffers_full > 0))
                {
                        ExplainIndentText(es);
                        appendStringInfoString(es->str, "WAL:");
@@ -4256,6 +4256,9 @@ show_wal_usage(ExplainState *es, const WalUsage *usage)
                        if (usage->wal_bytes > 0)
                                appendStringInfo(es->str, " bytes=" UINT64_FORMAT,
                                                                 usage->wal_bytes);
+                       if (usage->wal_buffers_full > 0)
+                               appendStringInfo(es->str, " buffers full=%lld",
+                                                                (long long) usage->wal_buffers_full);
                        appendStringInfoChar(es->str, '\n');
                }
        }
@@ -4267,6 +4270,8 @@ show_wal_usage(ExplainState *es, const WalUsage *usage)
                                                           usage->wal_fpi, es);
                ExplainPropertyUInteger("WAL Bytes", NULL,
                                                                usage->wal_bytes, es);
+               ExplainPropertyInteger("WAL Buffers Full", NULL,
+                                                          usage->wal_buffers_full, es);
        }
 }