Re: explain HashAggregate to report bucket and memory stats

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Subject: Re: explain HashAggregate to report bucket and memory stats
Date: 2020-03-06 19:43:07
Message-ID: 20200306194307.qeobgf3bklqodecv@development
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 06, 2020 at 09:58:59AM -0800, Andres Freund wrote:
> ...
>
>> + }
>> + else if (!inst->nbuckets)
>> + ; /* Do nothing */
>> + else
>> + {
>> + if (inst->nbuckets_original != inst->nbuckets)
>> + {
>> + ExplainIndentText(es);
>> + appendStringInfo(es->str,
>> + "Buckets: %ld (originally %ld)",
>> + inst->nbuckets,
>> + inst->nbuckets_original);
>> + }
>> + else
>> + {
>> + ExplainIndentText(es);
>> + appendStringInfo(es->str,
>> + "Buckets: %ld",
>> + inst->nbuckets);
>> + }
>> +
>> + if (es->analyze)
>> + appendStringInfo(es->str,
>> + " Memory Usage: hashtable: %ldkB, tuples: %ldkB",
>> + spacePeakKb_hash, spacePeakKb_tuples);
>> + appendStringInfoChar(es->str, '\n');
>
>I'm not sure I like the alternative output formats here. All the other
>fields are separated with a comma, but the original size is in
>parens. I'd probably just format it as "Buckets: %lld " and then add
>", Original Buckets: %lld" when differing.
>

FWIW this copies hashjoin precedent, which does this:

appendStringInfo(es->str,
"Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: %ldkB\n",
hinstrument.nbuckets,
...

I agree it's not ideal, but maybe let's not invent new ways to format
the same type of info.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chapman Flack 2020-03-06 19:53:23 Re: Unicode escapes with any backend encoding
Previous Message Kartyshov Ivan 2020-03-06 19:42:35 Re: [HACKERS] make async slave to wait for lsn to be replayed