mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-15 21:00:20 +02:00
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
0089dd34aa
commit
2b94b5ef8d
@ -267,10 +267,6 @@ ExecHashTableCreate(Hash *node, List *hashOperators, bool keepNulls)
|
|||||||
OidIsValid(node->skewTable),
|
OidIsValid(node->skewTable),
|
||||||
&nbuckets, &nbatch, &num_skew_mcvs);
|
&nbuckets, &nbatch, &num_skew_mcvs);
|
||||||
|
|
||||||
#ifdef HJDEBUG
|
|
||||||
printf("nbatch = %d, nbuckets = %d\n", nbatch, nbuckets);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* nbuckets must be a power of 2 */
|
/* nbuckets must be a power of 2 */
|
||||||
log2_nbuckets = my_log2(nbuckets);
|
log2_nbuckets = my_log2(nbuckets);
|
||||||
Assert(nbuckets == (1 << 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->spaceAllowed * SKEW_WORK_MEM_PERCENT / 100;
|
||||||
hashtable->chunks = NULL;
|
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
|
* Get info about the hash functions to be used for each hash key. Also
|
||||||
* remember whether the join operators are strict.
|
* remember whether the join operators are strict.
|
||||||
@ -615,8 +616,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
|
|||||||
Assert(nbatch > 1);
|
Assert(nbatch > 1);
|
||||||
|
|
||||||
#ifdef HJDEBUG
|
#ifdef HJDEBUG
|
||||||
printf("Increasing nbatch to %d because space = %lu\n",
|
printf("Hashjoin %p: increasing nbatch to %d because space = %zu\n",
|
||||||
nbatch, (unsigned long) hashtable->spaceUsed);
|
hashtable, nbatch, hashtable->spaceUsed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
oldcxt = MemoryContextSwitchTo(hashtable->hashCxt);
|
oldcxt = MemoryContextSwitchTo(hashtable->hashCxt);
|
||||||
@ -731,8 +732,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HJDEBUG
|
#ifdef HJDEBUG
|
||||||
printf("Freed %ld of %ld tuples, space now %lu\n",
|
printf("Hashjoin %p: freed %ld of %ld tuples, space now %zu\n",
|
||||||
nfreed, ninmemory, (unsigned long) hashtable->spaceUsed);
|
hashtable, nfreed, ninmemory, hashtable->spaceUsed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -747,7 +748,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
|
|||||||
{
|
{
|
||||||
hashtable->growEnabled = false;
|
hashtable->growEnabled = false;
|
||||||
#ifdef HJDEBUG
|
#ifdef HJDEBUG
|
||||||
printf("Disabling further increase of nbatch\n");
|
printf("Hashjoin %p: disabling further increase of nbatch\n",
|
||||||
|
hashtable);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -767,8 +769,8 @@ ExecHashIncreaseNumBuckets(HashJoinTable hashtable)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef HJDEBUG
|
#ifdef HJDEBUG
|
||||||
printf("Increasing nbuckets %d => %d\n",
|
printf("Hashjoin %p: increasing nbuckets %d => %d\n",
|
||||||
hashtable->nbuckets, hashtable->nbuckets_optimal);
|
hashtable, hashtable->nbuckets, hashtable->nbuckets_optimal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hashtable->nbuckets = hashtable->nbuckets_optimal;
|
hashtable->nbuckets = hashtable->nbuckets_optimal;
|
||||||
@ -814,11 +816,6 @@ ExecHashIncreaseNumBuckets(HashJoinTable hashtable)
|
|||||||
HJTUPLE_MINTUPLE(hashTuple)->t_len);
|
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
Block a user