aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-02-06 15:05:23 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-02-06 15:05:23 -0500
commit2b94b5ef8df1b037307634f8d0f881e2651d654e (patch)
tree23116f9495ac24df2775aa0a314bfd9e3a3f639c /src/backend/executor
parent0089dd34aa9bc5a1272c4c2fbcf183a0f983cf73 (diff)
downloadpostgresql-2b94b5ef8df1b037307634f8d0f881e2651d654e.tar.gz
postgresql-2b94b5ef8df1b037307634f8d0f881e2651d654e.zip
Improve HJDEBUG code a bit.
Commit 30d7ae3c76d2de144232ae6ab328ca86b70e72c3 introduced an HJDEBUG stanza that probably didn't compile at the time, and definitely doesn't compile now, because it refers to a nonexistent variable. It doesn't seem terribly useful anyway, so just get rid of it. While I'm fooling with it, use %z modifier instead of the obsolete hack of casting size_t to unsigned long, and include the HashJoinTable's address in each printout so that it's possible to distinguish the activities of multiple hashjoins occurring in one query. Noted while trying to use HJDEBUG to investigate bug #13908. Back-patch to 9.5, because code that doesn't compile is certainly not very helpful.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/nodeHash.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 5e05ec3df37..e7e51d17172 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
}