+ /* hashtable->entrysize includes additionalsize */ + hashtable->instrument.space_peak_hash = Max( + hashtable->instrument.space_peak_hash, + hashtable->hashtab->size * sizeof(TupleHashEntryData)); + + hashtable->instrument.space_peak_tuples = Max( + hashtable->instrument.space_peak_tuples, + hashtable->hashtab->members * hashtable->entrysize);
I think, in general, we should avoid estimates/projections for reporting and try to get at a real number, like MemoryContextMemAllocated(). (Aside: I may want to tweak exactly what that function reports so that it doesn't count the unused portion of the last block.) For instance, the report is still not accurate, because it doesn't account for pass-by-ref transition state values. To use memory-context-based reporting, it's hard to make the stats a part of the tuple hash table, because the tuple hash table doesn't own the memory contexts (they are passed in). It's also hard to make it per-hashtable (e.g. for grouping sets), unless we put each grouping set in its own memory context. Also, is there a reason you report two different memory values (hashtable and tuples)? I don't object, but it seems like a little too much detail. Regards, Jeff Davis