From: Tomas Vondra <tv@fuzzy.cz>
To: pgsql-performance@postgresql.org
Subject: Re: queries with DISTINCT / GROUP BY giving different plans
Date: Tue, 20 Aug 2013 17:13:09 +0200
Message-ID: <52138785.8010607@fuzzy.cz> (raw)
In-Reply-To: <520E7F33.7010305@fuzzy.cz>
References: <3a56c4d2c0b2daa11a625c2983823901.squirrel@sq.gransy.com>
<11586.1376505314@sss.pgh.pa.us>
<520E7F33.7010305@fuzzy.cz>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
On 16.8.2013 21:36, Tomas Vondra wrote:
>
> Now, the difference between 24 and 56 is caused by hash_agg_entry_size.
> It's called with numAggs=0 but returns 32. I'm wondering if it should
> return 0 in such cases, i.e. something like this:
>
> Size
> hash_agg_entry_size(int numAggs)
> {
> Size entrysize;
>
> if (numAggs == 0)
> return 0;
>
> /* This must match build_hash_table */
> entrysize = sizeof(AggHashEntryData) +
> (numAggs - 1) * sizeof(AggStatePerGroupData);
> entrysize = MAXALIGN(entrysize);
> /* Account for hashtable overhead (assuming fill factor = 1) */
> entrysize += 3 * sizeof(void *);
> return entrysize;
> }
>
> I've tested that after this both queries use HashAggregate (which is the
> right choice), but I haven't done any extensive checking so maybe I'm
> missing something.
So, is this a sufficient / correct explanation? Any comments about the
fix I suggested? Or should I try to get a permission to provide the data
so that you can reproduce the issue on your own? That might take a few
days to get through.
Tomas
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tv@fuzzy.cz
Subject: Re: queries with DISTINCT / GROUP BY giving different plans
In-Reply-To: <52138785.8010607@fuzzy.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox