Improve HJDEBUG code a bit.
Commit 30d7ae3c76
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.
This commit is contained in:
parent
392998bc58
commit
be11f8400d
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue