diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 8a8fdf2c8abf7554ffd5fb1e2aec08db4888d66a..d5a6892f7bc1de835cba15d918803f261f9b0df0 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -267,10 +267,6 @@ ExecHashTableCreate(Hash *node, List *hashOperators, bool keepNulls)
 							OidIsValid(node->skewTable),
 							&nbuckets, &nbatch, &num_skew_mcvs);
 
-#ifdef HJDEBUG
-	printf("nbatch = %d, nbuckets = %d\n", nbatch, nbuckets);
-#endif
-
 	/* nbuckets must be a power of 2 */
 	log2_nbuckets = my_log2(nbuckets);
 	Assert(nbuckets == (1 << log2_nbuckets));
@@ -311,6 +307,11 @@ ExecHashTableCreate(Hash *node, List *hashOperators, bool keepNulls)
 		hashtable->spaceAllowed * SKEW_WORK_MEM_PERCENT / 100;
 	hashtable->chunks = NULL;
 
+#ifdef HJDEBUG
+	printf("Hashjoin %p: initial nbatch = %d, nbuckets = %d\n",
+		   hashtable, nbatch, nbuckets);
+#endif
+
 	/*
 	 * Get info about the hash functions to be used for each hash key. Also
 	 * remember whether the join operators are strict.
@@ -615,8 +616,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
 	Assert(nbatch > 1);
 
 #ifdef HJDEBUG
-	printf("Increasing nbatch to %d because space = %lu\n",
-		   nbatch, (unsigned long) hashtable->spaceUsed);
+	printf("Hashjoin %p: increasing nbatch to %d because space = %zu\n",
+		   hashtable, nbatch, hashtable->spaceUsed);
 #endif
 
 	oldcxt = MemoryContextSwitchTo(hashtable->hashCxt);
@@ -731,8 +732,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
 	}
 
 #ifdef HJDEBUG
-	printf("Freed %ld of %ld tuples, space now %lu\n",
-		   nfreed, ninmemory, (unsigned long) hashtable->spaceUsed);
+	printf("Hashjoin %p: freed %ld of %ld tuples, space now %zu\n",
+		   hashtable, nfreed, ninmemory, hashtable->spaceUsed);
 #endif
 
 	/*
@@ -747,7 +748,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
 	{
 		hashtable->growEnabled = false;
 #ifdef HJDEBUG
-		printf("Disabling further increase of nbatch\n");
+		printf("Hashjoin %p: disabling further increase of nbatch\n",
+			   hashtable);
 #endif
 	}
 }
@@ -767,8 +769,8 @@ ExecHashIncreaseNumBuckets(HashJoinTable hashtable)
 		return;
 
 #ifdef HJDEBUG
-	printf("Increasing nbuckets %d => %d\n",
-		   hashtable->nbuckets, hashtable->nbuckets_optimal);
+	printf("Hashjoin %p: increasing nbuckets %d => %d\n",
+		   hashtable, hashtable->nbuckets, hashtable->nbuckets_optimal);
 #endif
 
 	hashtable->nbuckets = hashtable->nbuckets_optimal;
@@ -814,11 +816,6 @@ ExecHashIncreaseNumBuckets(HashJoinTable hashtable)
 							HJTUPLE_MINTUPLE(hashTuple)->t_len);
 		}
 	}
-
-#ifdef HJDEBUG
-	printf("Nbuckets increased to %d, average items per bucket %.1f\n",
-		   hashtable->nbuckets, batchTuples / hashtable->nbuckets);
-#endif
 }