From 49e4d0c154b4841c6f0c111bad2e4bab3b0ce8fe Mon Sep 17 00:00:00 2001
From: benoit <benoit.lobreau@dalibo.com>
Date: Tue, 8 Oct 2024 12:39:41 +0200
Subject: [PATCH 1/3] Add a guc for parallel worker logging

The new guc log_parallel_workers controls whether a log message is
produced to display information on the number of workers spawned when a
parallel query or utility is executed.

The default value is `none` which disables logging. `all` displays
information for all parallel queries, whereas `shortage` displays
information only when the number of workers launched is lower than the
number of planned workers.

This new parameter can help database administrators and developers
diagnose performance issues related to parallelism and optimize the
configuration of the system accordingly.
---
 src/backend/utils/misc/guc_parameters.dat | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat
index 83af594d4af..72ef1354091 100644
--- a/src/backend/utils/misc/guc_parameters.dat
+++ b/src/backend/utils/misc/guc_parameters.dat
@@ -1785,6 +1785,14 @@
   assign_hook => 'assign_log_min_messages',
 },
 
+{ name => 'log_parallel_workers', type => 'enum', context => 'PGC_SUSET', group => 'LOGGING_WHAT',
+  short_desc => 'Log information about parallel worker usage.',
+  long_desc => '"none" doesn\'t log anything, "all" logs all parallel worker usage and "shortage" logs only when the planned workers couldn\'t be acquired',
+  variable => 'log_parallel_workers',
+  boot_val => 'LOG_PARALLEL_WORKERS_NONE',
+  options => 'log_parallel_workers_options',
+},
+
 { name => 'log_parameter_max_length', type => 'int', context => 'PGC_SUSET', group => 'LOGGING_WHAT',
   short_desc => 'Sets the maximum length in bytes of data logged for bind parameter values when logging statements.',
   long_desc => '-1 means log values in full.',
-- 
2.47.3

