From d011edabb6cda6fce4b06c2b08e389ae11c7470c Mon Sep 17 00:00:00 2001
From: Sami Imseih <simseih@amazon.com>
Date: Wed, 8 Jan 2025 11:20:59 -0600
Subject: [PATCH v2 1/1] improve DEBUG1 logging of parallel workers for CREATE
 INDEX

---
 src/backend/access/brin/brin.c      | 4 ++++
 src/backend/access/nbtree/nbtsort.c | 4 ++++
 src/backend/catalog/index.c         | 5 ++---
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 9a98454757..7f72e5a4f9 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -2512,6 +2512,10 @@ _brin_begin_parallel(BrinBuildState *buildstate, Relation heap, Relation index,
 	brinleader->walusage = walusage;
 	brinleader->bufferusage = bufferusage;
 
+	ereport(DEBUG1,
+			(errmsg_internal("launched %d parallel workers for index creation (planned: %d)",
+							 pcxt->nworkers_launched, pcxt->nworkers_to_launch)));
+
 	/* If no workers were successfully launched, back out (do serial build) */
 	if (pcxt->nworkers_launched == 0)
 	{
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 7aba852db9..fe13f5fedf 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -1582,6 +1582,10 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
 	btleader->walusage = walusage;
 	btleader->bufferusage = bufferusage;
 
+	ereport(DEBUG1,
+			(errmsg_internal("launched %d parallel workers for index creation (planned: %d)",
+							 pcxt->nworkers_launched, pcxt->nworkers_to_launch)));
+
 	/* If no workers were successfully launched, back out (do serial build) */
 	if (pcxt->nworkers_launched == 0)
 	{
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 221fbb4e28..40b97c3885 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -3007,10 +3007,9 @@ index_build(Relation heapRelation,
 								 RelationGetRelationName(heapRelation))));
 	else
 		ereport(DEBUG1,
-				(errmsg_internal("building index \"%s\" on table \"%s\" with request for %d parallel workers",
+				(errmsg_internal("building index \"%s\" on table \"%s\" with parallel workers",
 								 RelationGetRelationName(indexRelation),
-								 RelationGetRelationName(heapRelation),
-								 indexInfo->ii_ParallelWorkers)));
+								 RelationGetRelationName(heapRelation))));
 
 	/*
 	 * Switch to the table owner's userid, so that any index functions are run
-- 
2.39.5 (Apple Git-154)

