MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecHashTableExplainBatchEnd

Function ExecHashTableExplainBatchEnd

src/backend/executor/nodeHash.c:2809–2913  ·  view source on GitHub ↗

* ExecHashTableExplainBatchEnd * Called at end of each batch to collect statistics for EXPLAIN ANALYZE. */

Source from the content-addressed store, hash-verified

2807 * Called at end of each batch to collect statistics for EXPLAIN ANALYZE.
2808 */
2809void
2810ExecHashTableExplainBatchEnd(HashState *hashState, HashJoinTable hashtable)
2811{
2812 int curbatch = hashtable->curbatch;
2813 HashJoinTableStats *stats = hashtable->stats;
2814 HashJoinBatchStats *batchstats = &stats->batchstats[curbatch];
2815
2816 Assert(!hashtable->eagerlyReleased);
2817
2818 /* Already reported on this batch? */
2819 if ( stats->endedbatch == curbatch
2820 || curbatch >= hashtable->nbatch || !hashtable->first_pass)
2821 return;
2822 stats->endedbatch = curbatch;
2823
2824 /* Update high-water mark for work_mem actually used at one time. */
2825 if (stats->workmem_max < hashtable->spaceUsed)
2826 stats->workmem_max = hashtable->spaceUsed;
2827
2828 /* Final size of hash table for this batch */
2829 batchstats->hashspace_final = hashtable->spaceUsed;
2830
2831 /* Collect buffile I/O statistics. */
2832 /* Parallel hash join uses shared tuplestores, don't consider it now. */
2833 if (hashtable->parallel_state == NULL)
2834 {
2835 if (hashtable->nbatch > 1)
2836 {
2837 uint64 owrbytes = 0;
2838 uint64 iwrbytes = 0;
2839
2840 Assert(stats->batchstats &&
2841 hashtable->nbatch <= stats->nbatchstats);
2842
2843 /* for curbatch=0, the inner tuple is in the in-memory hash table, the outer tuple is
2844 * read from outer relation, nothing need to read from batch file, but the innerfilesize
2845 * is initialized to 0 and the outerBatchFile[0] is initialized to NULL.
2846 * for curbatch>0, the inner tuple and outer tuple are read from batch file.
2847 */
2848
2849 /* How much was read from inner buffile for current batch? */
2850 batchstats->irdbytes = batchstats->innerfilesize;
2851
2852 /* How much was read from outer buffiles for current batch? */
2853 if (hashtable->outerBatchFile &&
2854 hashtable->outerBatchFile[curbatch] != NULL)
2855 {
2856 batchstats->ordbytes = BufFileSize(hashtable->outerBatchFile[curbatch]);
2857 }
2858
2859 /* for curbatch=0, the tuple which is not belong to the batch 0 is put into the temp
2860 * file for later batches.
2861 * for curbatch>0, It's possible that we increase the number, so that by the time we
2862 * reload curbatch file, some of the tuples we wrote here will logically belong to a later
2863 * file, they may be sent to future batches, so we count the increasing size here.
2864 */
2865
2866 /* How much was written to buffiles for the remaining batches? */

Callers 3

ExecHashTableExplainEndFunction · 0.85
ExecHashJoinNewBatchFunction · 0.85
ReleaseHashTableFunction · 0.85

Calls 2

BufFileSizeFunction · 0.85
cdbexplain_agg_updFunction · 0.85

Tested by

no test coverage detected